Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Here's my hosts(with a single entry):

127.0.0.1 test

But it's not working any more:

C:\Documents and Settings\Administrator>ping test
Ping request could not find host test. Please check the name and try again.

Why?

UPDATE

It stops working ever since I used openvpn

UPDATE2

alt text

share|improve this question
    
Perhaps the original one is encoded as something other than plain-text. Try renaming the file and creating a new plain-text file. –  Synetech Aug 6 '11 at 3:48

7 Answers 7

I had a similar problem trying to ping a machine across our VPN

I made two identical entries, each on a separate line, and that made it work

share|improve this answer

I had the same problem none of presented suggestions worked for me. I found the clue there: http://serverfault.com/a/50950/161292

I rigth-clicked on hosts file and went to Properties->Security->Advanced. then I checked Inherit from Parent and clicked 'apply'. That solved my problem.

share|improve this answer

You have a strange problem! But here are some ideas.

a)make sure you're opening the right file
notepad C:\WINDOWS\system32\drivers\etc\hosts

b)Check that the file path is right here at this registry key. Check that the path there is The actual HOSTS file location HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath

check that DataBasePath has value %SystemRoot%\System32\drivers\etc

c)you could also try running hijackthis. See if it lists something with key o1, that's host file redirection.. or something to do with it. you could then check the box and choose "fix checked"

You could give it up and do a system restore, which is likely to fix it if you can go back to a good time but it won't tell you what was wrong.. maybe some people will have some other ideas.

share|improve this answer
    
I've uploaded a snapshot of the register entries,and the value of DataBasePath is OK... –  fms Jan 9 '11 at 10:25
    
here's a long-shot, in internet explorer tools options connections, is proxy server unchecked? that is a general windows setting 'cos it affects chrome too. But it doesn't affect ping.. and probably wouldn't affect hosts either.. though i've heard of people using proxies for dns.. but worth a look. –  barlop Jan 9 '11 at 10:54
    
this answer superuser.com/questions/86751/… suggests some things, like sfc /scannow But it looks like the guy mainly just did an install of service packs and updates. So, I reckon a repair installation would have fixed it for him. Similarly, a system restore. But you may want to hang about and see if anybody has an interesting idea! –  barlop Jan 9 '11 at 10:57
    
@barlop: It certainly doesn't affect lower level tools such as ping. –  grawity Jan 9 '11 at 12:27
    
@gravvity as I thought then! –  barlop Jan 9 '11 at 16:02

If you just edited your host file, you maybe need to flush your dns table

ipconfig -flushdns

ping test

share|improve this answer
    
I think it might be ipconfig /flushdns. At least it is on XP. –  jmort253 Jan 9 '11 at 10:29
    
I just tried ,still not working.. –  fms Jan 9 '11 at 10:32

Your host file NEEDS the first entry to be 127.0.0.1 localhost to properly function, according to Microsoft. That may be an issue as well. Add that in then reboot and try

share|improve this answer
    
No, it doesn't have to be the first entry, and Windows 7 doesn't even put localhost to the hosts file. –  grawity Oct 7 '11 at 16:57
    
You're right that it doesn't need to be the first entry, my mistake. However, EVERY Windows 7 installation has it in there that I've seen –  Canadian Luke Oct 7 '11 at 17:24
    
They are commented-out, however, and ignored by the resolver. –  grawity Oct 7 '11 at 17:26

Check the advaced settings of your TCP/IP settings, make sure the LMHOSTS option is enabled.

enter image description here

share|improve this answer
2  
LMHOSTS is a separate file from HOSTS, and only used for NetBIOS lookups. –  grawity Oct 7 '11 at 16:57
1  
@grawity: That's true, but I've experienced that this setting applies to both files. –  Tom Wijsman Oct 7 '11 at 18:15

Maybe this is overstating the obvious; The hosts file resides in C:\Windows\System32\drivers\etc if you have edited this file in a text editor ensure that it hasnt added an extension, as far as windows is concerned the file must have no extension ie hosts. not hosts.txt

share|improve this answer
    
You could also try: netsh interface ipv4 reset ipconfig /flushdns ipconfig /registerdns –  Antony May 24 '12 at 13:14

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.