HOSTS File Edit in Windows 7 Not Effective - Pinging URL Still Shows Original IP Address

10,926

Solution 1

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.

Solution 2

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.

Solution 3

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.

Solution 4

The user indicated he fixed the problem though properly overwriting the contents of the host file in notepad (https://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.

Solution 5

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:
10,926

Related videos on Youtube

Sootah
Author by

Sootah

Updated on September 17, 2022

Comments

  • Sootah
    Sootah almost 2 years

    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

    • Richard
      Richard almost 14 years
      Win7 does use its hosts file, I use it here to translate my router's ip into a hostname to speed up tracert.
  • Sootah
    Sootah almost 14 years
    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?
  • Tamara Wijsman
    Tamara Wijsman almost 14 years
    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
  • elwyn
    elwyn about 13 years
    +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...
  • Arjan
    Arjan almost 11 years
    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. :-)
  • Manimaran
    Manimaran almost 11 years
    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.
  • Arjan
    Arjan almost 11 years
    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
    Arjan almost 11 years
    ...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?)
  • Sootah
    Sootah over 10 years
    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.