Why does my hostname revert to "localhost" everytime I restart?

steveluscher

Member
Feb 11, 2006
14
0
151
The first time I restarted my server, all of the cPanel/WHM stuff stopped working. Turned out it was a matter of the hostname having reverted back to localhost from my usual "server.mydomain.com".

I've edited the /etc/hosts file but when I restart, something messes up the /etc/hosts file and the hostname goes back to "localhost"

Any ideas on how I can make my changes stick?
Steve!
 

steveluscher

Member
Feb 11, 2006
14
0
151
An update:

Try as I might, setting the hostname in /etc/sysconfig/network doesn't help. The hostname in /etc/sysconfig/network itself reverts back to localhost.localdomain on reboot! What's editing this file at startup?
 

madaboutlinux

Well-Known Member
Jan 24, 2005
1,051
2
168
Earth
Are you on a VPS server or do you have a dedicated server ?
If you are on VPS then you cannot change the Hostname from your end. You will have to contact the Hosting company as its is changed from the main VPS server. If its a Dedicated server you should re-check entires in
/etc/hosts
/etc/sysconfig/network
 
Last edited:

steveluscher

Member
Feb 11, 2006
14
0
151
Shekhar said:
Are you on a VPS server or do you have a dedicated server ?
Thank you for the reply! You are right... I found this in our knowledgebase, finally:

...The same is true for VPS systems, however, there is one additional step. Open a ticket with technical support requesting that the hostname be set statically in Virtuozzo. If this is not done, a reboot will set the hostname back to "localhost.localdomain".
 

Spiral

BANNED
Jun 24, 2005
2,018
8
193
I have the exact same problem with one of our server accounts that is a VPS system
and after a better part of a year getting no answers and the provider being no help,
I just wrote my own script that executes at boot and immediately resets the hostname,
/etc/hosts, and resolv.conf ....

A similiar script also runs hourly via cron and check to make sure nobody has screwed
around with the hostname while the server has been up and online and changes
all information back to my settings if any changes have been detected.