The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'General Discussion' started by steveluscher, Feb 12, 2006.

  1. steveluscher

    steveluscher Member

    Joined:
    Feb 11, 2006
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    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!
     
  2. steveluscher

    steveluscher Member

    Joined:
    Feb 11, 2006
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    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?
     
  3. madaboutlinux

    madaboutlinux Well-Known Member

    Joined:
    Jan 24, 2005
    Messages:
    1,052
    Likes Received:
    2
    Trophy Points:
    38
    Location:
    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
     
    #3 madaboutlinux, Feb 12, 2006
    Last edited: Feb 12, 2006
  4. steveluscher

    steveluscher Member

    Joined:
    Feb 11, 2006
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Thank you for the reply! You are right... I found this in our knowledgebase, finally:

     
  5. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    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.
     
  6. acenetryan

    acenetryan Well-Known Member
    PartnerNOC

    Joined:
    Aug 21, 2005
    Messages:
    197
    Likes Received:
    1
    Trophy Points:
    18
    If you are the server's administrator and have access to VZMC or VZCP, try setting the hostname directly within your panel. This should keep the hostname from changing on boots.
     
Loading...

Share This Page