LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   /etc/hosts entry? (https://www.linuxquestions.org/questions/linux-newbie-8/etc-hosts-entry-305244/)

batard 03-23-2005 05:23 PM

/etc/hosts entry?
 
This is probably a really dumb question, but here goes: Whenever I login to Gnome in FC3, whether as root or another user, I get a message that says "localhost could not be found. Gnome programs may not function properly. Adding localhost to your /etc/hosts file may fix this problem." I of course added a line to my /etc/hosts file that says localhost, but that didn't work. I also removed every reference I could find to localhost in settings -- I think I called my computer "localhost" at some point; I'm not sure. Anyone know what's going on here?

gt_swagger 03-23-2005 05:50 PM

You don't just add "localhost"

echo "127.0.0.1 localhost" >> /etc/hosts

soulstace 03-23-2005 06:16 PM

Correct. You must have both the IP address and hostname in the hosts file because the file provides a way for the machine to map IP address to hostname. Therefore just having one or the other and leaving one of them out wont do.

batard 03-23-2005 09:11 PM

Indeed, that solved it. Thanks a bunch.

Batard

batard 03-25-2005 09:49 AM

Actually, I found out the hard way that putting "127.0.0.1 localhost" in your /etc/hosts is not good syntax. It seemed to work at first because the warning didn't appear when logging out/back in. But when you reboot the system, it completely hangs at sendmail startup and you have to get out your trusty rescue disk to save the day. The proper syntax, in fact, is

127.0.0.1 localhost.localdomain.localhost localhost

That's what should be in /etc/hosts. If your host is not called localhost but is called SomethingElse, it should be

127.0.0.1 localhost.localdomain.SomethingElse localhost

Komakino 03-25-2005 01:22 PM

Code:

127.0.0.1 localhost.localdomain.SomethingElse localhost
What's the SomethingElse for? localhost.localdomain covers everything that's needed, then the second localhost is the alias. Mine reads:
127.0.0.1 localhost.localdomain amelie


All times are GMT -5. The time now is 11:32 PM.