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 am running Windows 7 Home Premium 64-bit. Starting today, I noticed that DNS resolution is not reading my %SYSTEMROOT%\System32\drivers\etc\hosts file. I say this because I added two new entries to the file and when I run 'nslookup' on the command line, they don't resolve. Further, just trying to resolve 'localhost' results in my primary DNS server being queried.

I've read several threads that suggest that the file might have been corrupted and to move it aside and create a new one. I've done that, and no improvement.

Is there some sort of registry key that controls the sequence of resources used for DNS resolution (similar to nsswitch.conf on Unix)? What else could be causing this?

share|improve this question
I wonder, if you finally found a way to change this Windows 7 64-bit behavior, as I would require both methods (nslookup and ping) providing the same name resolution result! – user94345 Aug 16 '11 at 10:11
up vote 9 down vote accepted

When you run an nslookup on an address, Windows will query the DNS server and won't look in the hosts file. Always. However, when it actually goes to connect, it will use the host files value. Try adding to your hosts file, and have it point to Run an nslookup: it will resolve to the actual IP address. Ping it. Your localhost will respond.


Non-authoritative answer:


Pinging [] with 32 bytes of data:
Reply from bytes=32 time<1ms TTL=128
Reply from bytes=32 time<1ms TTL=128
Reply from bytes=32 time<1ms TTL=128
Reply from bytes=32 time<1ms TTL=128

Ping statistics for
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

share|improve this answer
Your example doesn't work on Windows 7 x64. ping says could not find host – Carlos Rendon May 21 '15 at 21:41

I have not managed to get my hosts file working on Windows 7 x64. The nasty thing is that with the exact same settings it works on x86.

So what I did, needing to block access to certain programs to certain sites was to use the free ZoneAlarm Personal Firewall. I know that this is the least elegant solution but for me there was no work around for this situation.

For me both ping and nslookup ignored the hosts file even though I have tried several versions and modifying to character encoding but with no success.

I don't know if anyone else could benefit from the solution I used, but just wanted to let you know that is exists and it works!

share|improve this answer

I struggled with this for too long, thinking that my antivirus software or something was the issue. In fact, my editor, Notepad, added the .txt extension to the file name, thus rendering it invisible for the system!

Check the extension. It should be empty! See also How can I reset the Hosts file back to the default?. This resets your host file back to original way it started out.

share|improve this answer

I had the same problem and this worked for me in Win 7.

When you add your new entries to the hosts file, make sure you use all spaces, no tabs.

That got it working for me.

share|improve this answer

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.