Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a HTTP server running on port 9876.

I put into Chrome and the page loads instantly.

I put http://localhost:9876/ into Chrome and the page never loads.

I have never modified C:\Windows\System32\drivers\etc\hosts.

Every line in the hosts file is commented out.

The following lines exist in the file and may be relevant:

# localhost name resolution is handled within DNS itself.
#       localhost

As I said, I have not added these lines myself. I have not edited the hosts file.

Obviously I can uncomment the second line to make localhost work. But why is this necessary if the first line is correct? Did Microsoft write the first line? It looks like they're telling me that localhost will work without being defined.

share|improve this question

migrated from Feb 7 '14 at 5:02

This question came from our site for system and network administrators.

Is your HTTP server also listening on ::1 or just IPv4? – jscott Feb 6 '14 at 15:33
Just ipv4 . . . – cja Feb 6 '14 at 15:33
uncomment it, and you got your localhost back) – alexus Feb 6 '14 at 15:52
The first line assumes you're running DNS on your box, and that localhost would resolve to your local IP. – Steve Butler Feb 6 '14 at 15:53
@SteveButler Ok, put that in an answer and I'll accept it. Also, can you explain why MS decided to disable localhost by default? – cja Feb 6 '14 at 16:04
up vote 0 down vote accepted

I can't find reliable documentation, but it appears since windows 7 they changed localhost resolution to DNS. I'm guessing the DNS client service actually hands back localhost when you do an operation, because your DNS server, where ever it is, probably wont resolve localhost. You can always set the hosts file, and it aught to override what the DNS client gives you.

Here's at least proof that it changed since windows 7:

I'm assuming its the DNS service, because on my Win8 box, those lines are commented, and yet localhost resolves back to ::1 and of course my DNS is not configured for IPv6, and even if it were, it wouldn't resolve localhost.

share|improve this answer

If you remove the second '#', localhost should work as well.


#     localhost

to     localhost
share|improve this answer
Sorry - I realise I didn't explain my understanding. Please see new final paragraph in question. – cja Feb 6 '14 at 15:36
'' is probably (hard)coded into the TCP/IP stack but not 'localhost' – Poliquin Feb 6 '14 at 15:43
What does the comment mean? It implies that localhost works without an entry in the hosts file – cja Feb 6 '14 at 15:43

The comment is talking about the DNS implementation in Windows itself, not the DNS implementation in Chrome.

share|improve this answer
That's what I thought – cja Feb 6 '14 at 17:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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