Possible reasons WINDOWS\system32\drivers\etc\hosts is not working (appart from the obvious)

16,604

Solution 1

From what you have done, and the list of things you have checked makes me think some sort of system failure as it looks like you have done the correct things, try doing "SFC /SCANNOW" from the command line just to test for system problems.

Solution 2

Next time, check \HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath in the registry to see if the location of your hosts file is correct and the same as where Windows assumes it to be.

Solution 3

Change hosts file owner to "Administrators" group. It fixed an issue for me.

Solution 4

Is this a problem with the hosts file not working or is it a problem with no DNS resolution at all working on the machine (ping, IE, etc.)?

If the latter, does nslookup work?

If so, take a look at When DNS and ping Fail but nslookup Works on my website for the long answer.

Short answer is that after trying all sorts of things, I ended up with "Winsock XP Fix" which someone built some years back after noting that the registry entries related to WinSock were actually the same between systems, and that sometimes they end up corrupted.

Share:
16,604

Related videos on Youtube

rwired
Author by

rwired

Never underestimate the importance of ‘Time-To-Market’ when planning software development. Perfection is a state of being attainable only in ever-increasing approximations, and never in entirety; and so the pursuit of perfection is a road taken incrementally with working releases along the way.

Updated on September 17, 2022

Comments

  • rwired
    rwired almost 2 years

    Here's my C:\WINDOWS\system32\drivers\etc\hosts file:

    127.0.0.1          localhost
    192.168.100.1      router
    

    testing it:

    C:\>ping router
    Ping request could not find host router. Please check the name and try again.
    
    C:\>ping 192.168.100.1
    
    Pinging 192.168.100.1 with 32 bytes of data:
    
    Reply from 192.168.100.1: bytes=32 time<1ms TTL=64
    Reply from 192.168.100.1: bytes=32 time<1ms TTL=64
    Reply from 192.168.100.1: bytes=32 time<1ms TTL=64
    Reply from 192.168.100.1: bytes=32 time<1ms TTL=64
    
    Ping statistics for 192.168.100.1:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 0ms, Average = 0ms
    

    It used to work. I used to have numerous redirects in there. But it stopped working a few weeks ago.

    I've checked all the obvious:

    • deleted the hosts file and replaced with this simple one just for testing
    • no invalid characters in the hosts file
    • no file extension on the hosts file
    • not using TAB to separate IP and hostname (tried using exactly 8 spaces)
    • ipconfig /flushdns
    • restart the DNS Client service
    • permissions on the file matches the permissions of the DNS Client (I've also tried "allow" for "everyone" on both the hosts file, and the "etc" folder, and also the "drivers" folder).
    • tried adding the NETWORK SERVICE user, and the LOCAL SERVICE user to this file permissions
    • no anitivirus/spamware/malware/resident shields running on this particular machine
    • tried the hosts file both with UNIX and DOS EOL markers
    • reboot the machine

    What am I missing?

    • William Hilsum
      William Hilsum over 14 years
      Not an answer as it doesn't solve anything - but what you have done, and the list of things you have checked makes me think some sort of system failure as it looks like you have done the correct things, try doing "SFC /SCANNOW" from the command line just to test for system problems. If it does solve, tell me and I will write this as an answer.
    • rwired
      rwired over 14 years
      In essence I think you were right. I was unable to run SFC because I no longer have my install disks (the installation is years old when I was working in a different company). However after managing to install SP1 and SP2 and applying all windows updates the hosts file is now working. Please post a separate answer and I will accept it.
  • quack quixote
    quack quixote over 14 years
    +1 good diag tip, and nice article. wish you'd've included a link(s) to the fix here, and the caveat that it's only for XP and earlier. i wouldn't expect you to completely reproduce the article here (although it'd be welcome if you wanted), but a bit more info in your summary would be appreciated.
  • rwired
    rwired over 14 years
    I will try that, although DNS and ping are working just fine for normal sites.
  • fencepost
    fencepost over 14 years
    I'll update this with more details when I get a few minutes over the holiday weekend.
  • Florenz Kley
    Florenz Kley over 9 years
    nice nugget :-0 after all that years