Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

4 Answers 4

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

share|improve this answer
    
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
show 2 more comments

Try this:

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

share|improve this answer
    
Still does not resolve test.dev... –  e100 May 5 '10 at 17:09
add comment

Have you tried either removing the line:

::1        localhost

or adding the line:

::1        test.dev

Update

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.

share|improve this answer
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
add comment
up vote 0 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

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.