I ran into the following problem under Windows 7: name resolution uses the result from a DNS lookup instead of using what I have in my local hosts file. This is different from previous versions of Windows. What workarounds are there to fix this bug?


My local hosts file contains the following entries (I disabled IPv6):

#       ::1             localhost               localhost               svn.mydomain

I can ping svn.mydomain and Windows 7 resolves the name as, as expected.

However, nslookup resolves svn.mydomain as, which is the entry that comes from my office network's domain nameserver. Windows XP correctly returns I recently moved the server in-house, which is why the svn.mydomain resolves through DNS now, but doesn't when I am outside the office network. I would prefer to not remove that host from DNS.

I specifically put this entry in hosts so I could create a secure tunnel to the Subversion repository on my server (localhost -> svn.mydomain) regardless of my network connection, and it is configured to respond only through a tunneled connection. This bug broke that solution and I'd really like to "resolve" (yes, pun intended) this problem.

How do I keep Windows 7 name resolution from overriding hosts entries?

  • Somebody over at StackOverflow directed me to this site as a better place to get my question answered.
    – Suncat2000
    Commented Mar 15, 2011 at 20:47

2 Answers 2


nslookup will return what the name servers actually return (as the name implies), but that's not the whole picture of name resolution. The hosts file takes priority, and netbios can be used, too.

As you've said, ping is working correctly, as should other applications that use the OS's name resolution functionality. nslookup's ignoring of the hosts file is inconsequential.

  • Thanks for the comment. I know that the hosts file should take priority, but that is not what Windows 7 is really doing. I'm trying to find out how to force it to take priority, as it did in previous versions of Windows.
    – Suncat2000
    Commented Mar 15, 2011 at 20:57
  • 1
    @Suncat2000 it already is priority; your ping command is evidence of this. nslookup ignores the hosts file, because that's how it works. But, SVN, web browsers, and everything else you might be needing this for, are already obeying your hosts file. Commented Mar 15, 2011 at 20:59
  • 1
    I assumed the identical behavior of my Subversion client and nslookup were due to the same reason. I'm embarrassed to say that was a bad assumption on my part. It was a faulty tunnel configuration that was making the Subversion connection fail. I was unaware that nslookup did not use all name resolution paths. Thanks for that fact.
    – Suncat2000
    Commented Mar 15, 2011 at 21:29

NSLOOKUP is not going to look at your HOSTS file... you are directly querying your DNS server. Hence, it will return your DNS server's record regardless of your local HOSTS file.

  • OK, thanks. But nslookup is behaving the same as my Subversion client, and anybody who would have an answer to my question has access to nslookup. The crux of the matter is that Windows 7's name resolution is somehow broken and I need a way to fix it.
    – Suncat2000
    Commented Mar 15, 2011 at 21:00

You must log in to answer this question.

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