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.

I've edited my HOSTS file on my Windows 7 Ultimate PC to re-route a couple of URLs so that they point to 127.0.0.1, but after saving the file (and re-opening to verify the changes were written) and pinging them they still reply with the actual IP instead of being redirected to 127.0.0.1 as they should be. At least, that's how it worked in XP, Vista, etc. I even went so far as to restart my DNS service on the machine via services.msc; but no dice.

So - I would imagine that Windows 7 keeps the HOSTS file there for legacy purposes and doesn't actually use it anymore. Is there a way to make W7 pay attention to the HOSTS file? In the event that you can't do that, where would I go to edit where these URLs point to?

Thanks in advance!

-Sootah

share|improve this question
    
Win7 does use its hosts file, I use it here to translate my router's ip into a hostname to speed up tracert. –  Richard Jul 7 '10 at 8:32

5 Answers 5

First, make sure your DNS Cache is empty:

ipconfig /flushdns

Then, go to the properties of your network device, in the advanced settings of the Internet Protocol you can enable the LMHOSTS look-up functionality, it should work if both were done; Windows 7 still supports the HOSTS file like in previous versions.

share|improve this answer
    
LMHOSTS is checked in the adapter's IPv4 settings, I've run ipconfig /flushdns, rebooted, etc and it still doesn't work. Do I have to do the manual "import LMHOSTS" deal? If so, what format is an LMHOSTS file in? Ideas? –  Sootah Jul 6 '10 at 23:04
    
Maybe that could work, it's somehow not loading the hosts file as it should be doing. I think the LMHOSTS are written in the same way, see: en.wikipedia.org/wiki/LMHOSTS –  Tom Wijsman Jul 6 '10 at 23:54

I had the same problem and was due to Trend Micro Antivirus. Go to your network device, in the properties (where you can see the IPv4, IPv6, etc.) uncheck the checkbox for "Trend Micro NDIS 6.0 Filter Driver". Wasn't enought deactivating the firewall! If you have installed another antivirus solution check if it's interfering.

share|improve this answer
up vote 6 down vote accepted

Alrighty guys, apparently Win7's hosts file is screwy in some way. If you copy the contents of the file and then paste it into a new txt document (Notepad), then go and delete the original hosts file out of Windows\System32\Drivers\etc followed by saving a new copy of hosts (in the etc directory, obviously) then it works.

I had this problem on both my Win 7 desktop as well as my laptop and the copy/delete/save new method worked on both.

share|improve this answer
    
+1 this did it for me also. Very strange, as I literally copy pasted the exact contents of my old file into a new file, and it suddenly started working... –  elwyn May 28 '11 at 23:21
    
For whoever is trying this in the future: it might be a nice test to COPY the file, then remove the original and finally rename the copy to the original name. Also, it might be nice to rename the original rather than deleting it, and then after saving the new one, compare the two files. Of course, all that is not needed to make things work, but some background might be nice. :-) –  Arjan Aug 13 '13 at 18:20
1  
Have you tried running notepad as administrator, then opening the hosts file? Not doing so won't allow you to overwrite changes. That's why you're having to do all this copy/delete/replace nonsense. –  Moses Aug 13 '13 at 18:21
    
Yes, I had run it as admin. I was able to save changes to the hosts file just fine - it just didn't do anything until I did the delete and replace. –  Sootah Dec 19 '13 at 23:37

Changes in file: hosts wasnt working for me, since I had an automated configuration script turned on in my LAN Settings. Please turn off the config script and hosts changes should show up.

share|improve this answer

The user indicated he fixed the problem though properly overwriting the contents of the host file in notepad (http://superuser.com/a/245561/201262) However:

There's a lot of discussion going on related to why the user needs to copy the contents of the host file to a new text document, delete the old, etc.

None of that is necessary.

When editing the hosts file, you need to first run notepad as administrator, then open the hosts file. Doing so will allow you to edit changes without having to save to a new location and replace.

share|improve this answer
    
Ah! I was about to comment "the accepted answer explains overwriting is even needed when the contents are the same". But obviously if the contents are the same as the sample HOSTS file, then such file is useless to start with. I cannot validate your claim, but it makes a lot of sense! –  Arjan Aug 13 '13 at 18:58
    
...however, the OP (and their self-answer) also writes "[...] but after saving the file (and re-opening to verify the changes were written) [...]" — so maybe there was something funny with the original file anyway. (Like maybe having some Unicode BOM or something like that?) –  Arjan Aug 14 '13 at 20:50

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.