Possible Duplicate:
Why is “127.0.0.1 localhost” needed in HOSTS file ?

Is localhost host resolved to 127.0.0.1?

If "yes", then why does everything (IIS , ASP.NET, MS SQL Server, webapps, sharepoint, etc.) work on my WIndows XP Pro SP3 exactly the same if I use 127.0.0.222 (or any loopback IP 127.0..0.*) instead of 127.0.0.1?

Is localhost well-known Windows identifier?

link|improve this question

Added Update1 and Related questions – WebMAOhist Aug 21 '10 at 5:15
@vgv8: please don't add unnecessary (un)related links to your question. Readability of the question is severly impacted – Sathya Aug 21 '10 at 14:49
@moderator, I cannot post any question in SU, MSU, SO, as well as edit my posts. Is it intentional? – WebMAOhist Aug 21 '10 at 17:38
Submitting question in SU, SO, MSU fails with: " Oops! Your question couldn't be submitted because: users with less than 100 reputation can only post questions every 20 minutes; try again later." though I had not submitted any question for the last 24 hours – WebMAOhist Aug 21 '10 at 17:40
@vgv8: Moderator swill not be updated by commenting on your question, only Sathya will and he is not a moderator as he doesn't wear a diamond after his name. You could place your problem on the meta site so that a moderator sees it or contact team@superuser.com if it's really urgent. – Tom Wijsman Aug 21 '10 at 19:03
show 1 more comment
feedback

migrated from stackoverflow.com Aug 21 '10 at 13:43

This question came from our site for professional and enthusiast programmers.

closed as exact duplicate by Sathya, Tom Wijsman, Diago Aug 21 '10 at 17:20

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.

4 Answers

up vote 5 down vote accepted

The Loopback device (aka Locahost) is mapped to the whole range of 127.0.0.0 to 127.255.255.255, which is why it 127.0.0.222 works:

The most commonly used IP address on the loopback device is 127.0.0.1 for IPv4, although any address in the range 127.0.0.0 to 127.255.255.255 is mapped to it.

Update

See this article on host name resolution (specific to 2003, but should apply to XP).

Possibilities:

  • Your DNS server is responding with localhost for any 127.* query (unlikely)
  • The entry is still cached (ipconfig /flushdns to clear it out)
  • You may have an lmhosts file that maps it

I have seen that the default networks file in windows contain loopback 127, which may be why this works.

It is also quite possible that the mapping loopback / localhost is built into the TCP/IP stack itself.

link|improve this answer
Thanks for try but see my Update1 in main question – WebMAOhist Aug 21 '10 at 5:06
@vgv8 - see my update. Perhaps this will provide a better answer. – Oded Aug 21 '10 at 5:25
feedback

What is your real question, then? If your real question is why any IP address with 127.x.y.z behaves as a loopback address, look at your routing table (on Windows, "route print"). You will see that addresses of the form 127.0.0.0 with netmask 255.0.0.0 will route to gateway 127.0.0.1 on the loopback interface.

link|improve this answer
feedback

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

link|improve this answer
You can check your hosts file in windows C:/system/system32/drivers/etc/hosts and yes. – Lavinski Aug 21 '10 at 4:52
@Lavinski, HOSTS is empty and localhost as well as 127.0.0.1 is working the same – WebMAOhist Aug 21 '10 at 5:00
@Webartб wikipedia is not the reason to dump my development. Can you give reference to MS docs? If "Localhost always translates to the loopback IP address 127.0.0.1", as stated there, then re-read my main question - why any 127.0.0.* loopback address works instead of 127.0.0.1? – WebMAOhist Aug 21 '10 at 5:03
The Wikipedia article states why, there is even a [3] reference behind it. -> The Internet Engineering Task Force (IETF) Internet Standard document STD-2 series (e.g., RFC 1700) reserved the 127.0.0.0/8 address block for loopback purposes. [ 3: tools.ietf.org/html/rfc1700 ] – Tom Wijsman Aug 21 '10 at 10:30
feedback

Anything in 127.* is a loopback address. On most OSes, only 127.0.0.1 is bound; Windows might well bind the loopback interface to 127.0.0.0/8 (i.e. if a server listens on 0.0.0.0 it might get connections to 127.0.0.2, whereas if it listens on 127.0.0.1 it might not get those connections).

Localhost often also (annoyingly) resolves to ::1 on many systems. I doubt this happens by default in Windows.

link|improve this answer
Have you read my question before answering, you would have come to ::1 also. This is discussed in the grandparent question linked from parent question. This was the reason of this subquestion and its parent. – WebMAOhist Aug 21 '10 at 4:54
feedback

Not the answer you're looking for? Browse other questions tagged or ask your own question.