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  localhost
::1        localhost  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?


Avoid multiple entires for the same IP — write multiple hostnames on the same line (with the first being the canonical name). e.g.: 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

  • The first part of this does seem to have worked! Many thanks. – e100 May 6 '10 at 10:18
  • Hmm, without any further changes to hosts, test.dev again does not resolve. The DNS Client service is disabled. Seems there's another issue here. – e100 May 10 '10 at 12:26
  • when you say “does not resolve” do you mean a ping test.dev from the command-line fails, or are you testing a different way? (Also, might be worth removing the test.dev from the ::1 line — if you're not properly set up for IPv6, it might confuse matters having it there). – Mo. May 10 '10 at 12:31
  • ping test.dev from command line now fails, with or without ::1 test.dev – e100 May 10 '10 at 12:44
  • okay, something else is going on somewhere, though I must confess I’m not sure what it might be — your hosts file is present (and correct as far as I can assume), the DNS caching service isn’t getting in the way to confuse matters. I’m a bit stumped. – Mo. May 10 '10 at 13:56

Try this:

# localhost
::1 localhost
::1 test.dev test.dev

  • Still does not resolve test.dev... – e100 May 5 '10 at 17:09

Have you tried either removing the line:

::1        localhost

or adding the line:

::1        test.dev


There used to be issues in the past if the hosts file contained spaces rather than tabs between the address and the name. I haven't checked recently enough to know whether that's still the case. You could try making sure that the delimiter is a tab rather than spaces.

  • 1
    Yes and yes, with no effect, but isn't that entry for IPv6 compatibility? – e100 May 5 '10 at 16:45
  • @elliot100 - I think so, I was just trying to suggest that you make the version that doesn't work identical to the version that does. – ChrisF May 5 '10 at 18:43

Having tried everything suggested here, I resolved the issue by reinstalling Windows.

  • Damn, those rare very cases where nuking is the only solution for rather stupid reasons :S – Marc.2377 Nov 26 '16 at 22:43

I was able to solve my problem by not using .dev as my TLD (Top Level Domain).

Apparently Google owns .dev, and has set up HSTS (HTTP Strict Transport Security) to ensure that all requests to any .dev site automatically redirect to https :(. I believe this is implemented in the browsers, and happened for me in both Chrome and Safari.

Solution: Use .test(or any other TLD) instead of .dev

Here's a link with more information about this topic: https://ma.ttias.be/chrome-force-dev-domains-https-via-preloaded-hsts/

  • 1
    See RFC 2606 and RFC 6761 before using any TLD. – Michael Hampton Feb 26 '18 at 3:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.