Windows 7 has easily been the best version of the operating system to date, by far. While Vista came with plenty of quirks, Microsoft seems to have learned from the mistakes made and corrected many of them for their release of 7. Unfortunately, nothing is perfect, and the odd quirk where Windows 7 ignores its hosts file is a good example of this. Fortunately for all of us – it’s easy to fix.
Description of problem:
Any custom entries in the Windows 7 hosts file get ignored. If, for example, you had “127.0.0.1 activate.adobe.com” put in there (we’ll ignore just why you might have that entry in there.. :) ) and then tried to ping that address, it would still reply with its actual IP instead of 127.0.0.1 as it should.
How to fix the Windows 7 hosts file:
1. First, in order to do any editing on the Windows 7 hosts file, you will need to open up Notepad as an administrator. To do this, Click on the Start button->Accessories, and then right-click on Notepad. A context menu will appear, then click on “Run as Administrator”
2. In Notepad, open up the hosts file located at C:\Windows\System32\drivers\etc. You’ll need to change the filter from “Text Documents (*.txt)” to “All Files” in order to see hosts listed.
3. Select all of the contents in the file (CTRL+A), copy them (CTRL+C), open up another instance of Notepad, and then paste the contents into the newly opened program. Close the Notepad you have the hosts file open in.
4. Now, rather counter-intuitively, you need to delete the original copy of the hosts file. Open up Windows Explorer (Start->Accessories->Windows Explorer), navigate to C:\Windows\System32\drivers\etc, and delete it. Windows will likely complain about it being a system file, etc – just ignore all that and proceed with the deletion.
5. In the Notepad you still have open, click “Save As” from the file menu, change the filter to “All Files”, type “hosts” into the file name textbox, and save it. Be sure to save it into the directory where you deleted the hosts file from originally, or else it won’t do any good.
6. TEST – This is easy enough to do. If you’re reading this then you likely already to know how to do this, but I’ll humor you anyway. Open up a command prompt and type “Ping WhatEverEntryYourRerouting.com” then press enter. Using the example above, then if you were to type “ping activate.adobe.com” then you should get four replies from 127.0.0.1.
Why was the Windows 7 hosts file not working?
I have utterly no idea. I’d suspect some sort of corruption with it, but since it opens properly in Notepad without any odd artifacts showing it’s hard to tell. There’s always a possibility that there are some non-standard whitespace characters in the original copy of the hosts file that don’t get brought over when the contents are copied and pasted, but who knows. I’ve tried just cutting the contents from the file and pasting them back in, followed by saving the file but for some reason it only works when the original is deleted and a new one is saved.