1834929 Members
2413 Online
110071 Solutions
New Discussion

Re: localhost

 
Javier Ortiz Guajardo
Frequent Advisor

localhost

Please help me to understand the use of the localhost in the /etc/hosts.

Who use it?
what happens if i put the hostname at the first line and the localhost in the second line?

What happens if i delete this line?

thanks you for your help.
The obstacles are those things that the people see when they left to see their goals.
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor

Re: localhost

Hi:

The entry 'localhost' is always defined as 127.0.0.1. It represents the host upon which you run.

The entry is used if/when you want to construct a TCP/IP communication with yourself.

The order of appearance in '/etc/hosts' (first, second, last, whatever) is immaterial.

The 'localhost' entity is also a useful in testing that basic networking is operating.

Regards!

...JRF...
Tor-Arne Nostdal
Trusted Contributor

Re: localhost

Why would you like to delete it...
There is no reason for doing so.

As James pinpointed it is used for communicating with "yourself".

Some programs might use this feature for specific purposes, and by disabling the 127.0.0.1 address (loopback) you might also cause these to fail.

Example: ssh with X display tunnel

You could also get into trouble with checking your network adapter.

Order of appearance:
The reason why it is the first address is that this is from base installation of the OS, before it actually have got assigned any IP-address.
It is a good habit to leave it as the first line, as it is more unlikely that you delete it as a mistake...

So - pls. let the entry stay for your own sake :-)

/Tor-Arne
I'm trying to become President of the state I'm in...
Bill Hassell
Honored Contributor

Re: localhost

localhost (and the special IP address) is used in many locations, from libraries to daemons. Even sendmail needs this entry. Your PC requires localhost and many anti-virus and anti-spyware programs use this address to alias bad addresses. For example, bad.website.com is often aliased to localhost so the URL won't work on your PC. localhost is quite pervasive as you can read in this reference:

http://en.wikipedia.org/wiki/Localhost

See also RFC 2606

http://www.rfc-editor.org/rfc/rfc2606.txt


Bill Hassell, sysadmin