I want to test some HTTP server on localhost address under Windows (XP) and I get strange behaviour: when I enter http://localhost/ in my browser I get connection reset error, while putting or anything other that is mapped to this address in the 'hosts' file works just fine and the start page is displayed.

I've closed some processes I suspected, disabled firewall, and it didn't help. For one moment the 'localhost' got back and then it's gone again without any reason. How can I track down what is meddling with localhost address under Windows?

Here is my 'hosts' file:       localhost       moin

The 'moin' entry works fine, 'localhost' is reset. The HTTP server is play! framework, and the way I must use it is 'http://localhost:9000/@tests'.

The ping response indicates that the 'localhost' resolves to IPv6 ::1 address:

C:\> ping localhost

Checking IZABELA [::1] using 32 bytes of data:

Response from ::1: time<1 ms
Response from ::1: time<1 ms
Response from ::1: time<1 ms
Response from ::1: time<1 ms
  • Could you post your hosts file? What HTTP server are you using?
    – beatgammit
    Apr 4, 2011 at 16:35

1 Answer 1


This is because your localhost passes your network adapter (note the LMHOSTS in it's advanced configuration, this does in essence turn processing of the HOSTS file on and off) and your network adapter could do something extra with it. If you visit then it directly goes to the loopback adapter, as for the other entries your network adapter might just choose to forward them instead of handling them (like the localhost entry). You can get routing information using route PRINT in a command prompt:

IPv4 Route Table
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
    281 <--         On-link    306 <==         On-link    306 <==         On-link    306 <==         On-link    281         On-link    281         On-link    281         On-link    276         On-link    276         On-link    276         On-link    276         On-link    276         On-link    276         On-link    306         On-link    276         On-link    276         On-link    281         On-link    306         On-link    276         On-link    276         On-link    281

Note where I set the <== at the end, these ensure that the interface is used when you visit a loopback address.

Note where I set the <-- at the end and means any IP, these ensure that things like localhost, any other thing you forward in HOSTS and most IPs you visit are handled by your network adapter which uses the interface and the gateway.

A higher metric means more priority, so this is why <== has preference over <--.

More information can be found on subnetworks to understand the netmasks.

As for your problem:

  • Check your IIS/Apache configuration.
  • Disable your anti virus and firewall.
  • Reset your network adapter to see if it solves the problem.
  • Use the Troubleshoot Problems option to see if it resolves something.
  • Use ipconfig /flushdns to clear DNS resolution.
  • See what you get for ping localhost.
  • Try to disable IPv6.
  • Update the drivers for your network adapter.

Report back if you still have the problem, you might want to capture a Wireshark trace.

  • The firewall was disabled, as I stated before. I've added ping response to my question. Resetting adapter didn't help. Flushing DNS also didn't help. Updating drivers is impossible. More ideas?
    – Rajish
    Apr 4, 2011 at 21:07
  • @Rajish: Hmm, IPv6, does the same problem occur when you disable IPv6 and thus only use IPv4? As localhost resolves to the IPv6 variant your server is most likely not listening to the IPv6 IP and thus localhost would not work. Updating your network drivers should be possible, why is it impossible? Apr 4, 2011 at 21:21
  • 1
    I have already the 'newest' drivers for my hardware. Disabling IPv6 at all did the trick. Before that I've tried the trick described here but it didn't work.
    – Rajish
    Apr 4, 2011 at 22:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .