My hosts file is broken (windows won't read it)

2

I have Windows 7 Pro 64 bit and it won't read the hosts file ! I've googled around for quite a long time but I can't fix it, maybe someone here can help me.

I can't see the .txt extension on the hosts file, but still windows opens it right away with notepad (so i don't know if it got corrupted somehow and it DOES have a .txt extension but I can't change it cause I can't see it).

If I go to cmdand type rename hosts.txt hosts it gives an error and says that

System couldn't find the file

If I try go to regedit and find

HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath=

I hit a wall because DataBasePath= IS NOT listed under parameters, it's like there's no entry. I don't know if my PC got infected with malware or something and it's hiding the hosts file from the registry and the system.

Tony

Posted 2011-07-06T18:34:47.200

Reputation: 23

Answers

9

It does NOT have any extension. It is a read-only file located here:

C:\Windows\System32\drivers\etc\hosts (name of file, no extension).

You can create an empty HOSTS file if you need to. There is only information, no real data in it by default.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters

DataBasePath should have a value of: %SystemRoot%\System32\drivers\etc

KCotreau

Posted 2011-07-06T18:34:47.200

Reputation: 24 985

ok the value of databasepath is correct, and I DO have a file called hosts in C:\Windows\System32\drivers\etc\ but it is already recognized as a notepad file even if the filename is hosts (and not hosts.txt).

How do I create a new hosts file, just by creating a new notepad file and naming it hosts ? – Tony – 2011-07-06T19:24:05.130

You are really kind, but I think I solved the issue, I just have to check haha... turns out windows wasn't showing extensions AT ALL so I couldn't delete the extension ... now the file is not recognized by any program (the icon displays as a blank paper)... Now, is there a way I can check if windows actually reads the file using cmd?... like a command or something? – Tony – 2011-07-06T20:03:03.770

I forgot to mention the obvious: I disabled the option under the folder options that hides known file extension, that way I could see that "hosts" was indeed "hosts.txt", so I deleted the ".txt" part and got a warning that said the file could be permanently damaged, I hit ok and the system no longer recognized the file. But I still need to check if the system reads the file, and I don't want to try and load an address on my browser cause I had them blocked for a good reason ! haha... maybe I can ping in cmd? – Tony – 2011-07-06T20:10:57.427

YES it works... (it says 100% lost)... THANK YOU so much ! haha... Now... any ideas why it happen? Was it my fault when trying to add new addresses to the file or could it be a virus?... (If I had to pick I'd say it is most likely my fault haha)... Thank you again really :D – Tony – 2011-07-06T20:15:33.167

Yes, you open a command box, and ping rhino.acme.com after you add that line to the HOSTS file. That line is a test line from the original HOSTS file. It will not return a reply, but the IP should be what is in the file, rather than getting the error "host unknown" – KCotreau – 2011-07-06T20:16:25.273

Hard to say since did not see it. But glad it is all set now. – KCotreau – 2011-07-06T20:17:35.537

wait... i "pinged" the address but using the numbers (102.54.94.97), not the actual address as i would do in my browser... but is the same right?? – Tony – 2011-07-06T20:18:56.063

No, the test is to ping rhino.acme.com. It should still say 100% lost, but it will resolve and tell you that it is pinging 102.54.94.97. The key is the HOSTS file is telling it to change that (known as resolving) rhino.acme.com into the IP address. – KCotreau – 2011-07-06T20:22:27.577

1

You can create a new hosts file and save it onto your desktop as hosts.txt. Then rename the file and remove the extension so that it's just hosts. Copy it to c:\windows\system32\drivers\etc and it will prompt you for with the UAC.

kobaltz

Posted 2011-07-06T18:34:47.200

Reputation: 14 361