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 127.0.0.1
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
0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.100 281 <--
127.0.0.0 255.0.0.0 On-link 127.0.0.1 306 <==
127.0.0.1 255.255.255.255 On-link 127.0.0.1 306 <==
127.255.255.255 255.255.255.255 On-link 127.0.0.1 306 <==
192.168.1.0 255.255.255.0 On-link 192.168.1.100 281
192.168.1.100 255.255.255.255 On-link 192.168.1.100 281
192.168.1.255 255.255.255.255 On-link 192.168.1.100 281
192.168.11.0 255.255.255.0 On-link 192.168.11.1 276
192.168.11.1 255.255.255.255 On-link 192.168.11.1 276
192.168.11.255 255.255.255.255 On-link 192.168.11.1 276
192.168.40.0 255.255.255.0 On-link 192.168.40.1 276
192.168.40.1 255.255.255.255 On-link 192.168.40.1 276
192.168.40.255 255.255.255.255 On-link 192.168.40.1 276
224.0.0.0 240.0.0.0 On-link 127.0.0.1 306
224.0.0.0 240.0.0.0 On-link 192.168.40.1 276
224.0.0.0 240.0.0.0 On-link 192.168.11.1 276
224.0.0.0 240.0.0.0 On-link 192.168.1.100 281
255.255.255.255 255.255.255.255 On-link 127.0.0.1 306
255.255.255.255 255.255.255.255 On-link 192.168.40.1 276
255.255.255.255 255.255.255.255 On-link 192.168.11.1 276
255.255.255.255 255.255.255.255 On-link 192.168.1.100 281
Note where I set the <==
at the end, these ensure that the 127.0.0.1
interface is used when you visit a loopback address.
Note where I set the <--
at the end and 0.0.0.0
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 192.168.1.100
interface and the 192.168.1.1
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.