Why is the hosts file not working

domain-name-systemhosts-filewindows-vista

I've been using the hosts file to for local website development, and it's recently stopped working. No entries other than localhost resolve.

I've simplified to test, so it now contains only

127.0.0.1  localhost
::1        localhost
127.0.0.1  test.dev

localhost responds to ping, test.dev does not.

  • The file is called hosts with no extension
  • It has no trailing spaces
  • It's saved in C:\WINDOWS\System32\drivers\etc which matches the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath
  • Oddly, despite UAC being on, I can edit, delete and save the file without admin permissions
  • No proxy is being used, PC is not connected to network for testing
  • Stopping the DNS Client service seemed to resolve the issue for a few minutes, test.dev briefly resolved but doesn't any more.
  • Only firewall is Windows'
  • Machine has been restarted.

Is there anything else I should try?

Best Answer

Avoid multiple entires for the same IP — write multiple hostnames on the same line (with the first being the canonical name). e.g.:

127.0.0.1 localhost localhost.localdomain test.dev

::1 localhost localhost.localdomain test.dev

If you’re still having problems, try (from a command prompt):

net stop dnscache