Windows 7 Hosts File Ignored
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 “activate.adobe.com 127.0.0.1″ 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 Win7 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.

Tweet This
Share on Facebook
Digg This
Save to delicious
Stumble it
RSS Feed
THANK YOU!! I’ve been struggling trying to get the hosts file to work in my new Windows 7 computer for about a week now. I tried changing the spacing from a single space to tabs, pasting in the hosts file from my old XP computer, etc to no avail. This is the only thing that got the hosts file working for me!
I’m soooo thankful!!!! I was struggling with the hosts file since my Windows 7 got updated two nights ago with the new SP1. I was completely out of ideas until I luckily ended up here. Just by duplicating the hosts file, deleting the old one, and renaming the new one, it worked again as before. Sometimes the simplest solutions are the good ones.
Thanks again. I mean it! :)
Well at least this fix was easy. I was going CRAZY trying to figure out why Win7′s hosts file wasn’t working, when the exact same one worked just fine for me in XP and Vista.
We only wasted two hours instead of eight. You are a god. Thank-you.
WOW! This simple step FINALLY allowed me to see my development site. Thanks for taking the time to write this!
I tried this, along with all other “fixes” I’ve been able to find…nothing seems to fix this issue for me…Any other ideas?
Thanks
I’ve been struggling with this for weeks.
thanks so much. it works now. :)
Oh man, FINALLY! I’ve been working around Adobe’s stupid activation for a while now due to some licensing issues that are taking forever to resolve. I can’t believe that’s all it took to get Windows 7 to actually USE the hosts file!
2 ways to fix the problem :
first one
1- right click – properties – security
2- check write permission
second one
1-download windows 7 manager-15 days no limit fully working
2-install it
3-run the program and then go to IE manager tab
there you can edit the host file
Thanks man .. it worked like a charm, so solved my oldest problem on windows 7 ::)
Still an issue on my end. This fix successfully returns pings from 127.0.0.1 but it all browsers are still unable to resolve the domain. Anybody else get around this?
Hello guys,i did what you said but i still have the same problem!!!
So the problem: On initial install, the Windows 7 hosts file is a symlink to another location. Unfortunately, Windows 7 sees this as a security threat and, as a result, ignores it.
The simple solution is to just open the file, copy its contents, remove the link, and recreate a real file in its place.
The use of the HOSTS file is also affected by whether or not the Windows 7 machine is a member of a domain.
I’m from the fedora linux world, so note-pad was confusing reL how to get it to not save as hosts.txt (which is not detectable by looking at the name as it appears in windows nautilus-like program confusingly called “windows explorer”. However properties window revals actual name is hosts.txt
Work-around: When saving the hosts file, use “file -> save as” with the following:
1. Filter set to All Files (not as txt/text file)
2. must call it “hosts.” (calling it hosts makes notepad call it hosts.txt)
Now I can ping the webserver running on my LAN!
Tried the above and the ‘ping’ does not show 127.0.0.1 as you mentioned
Works great. Thanks for sharing! I’m happy to let the mystery be as long as I can fix it.
I have to admit…. I smirked when I read that all I needed to do was delete the original and replace it with a copy.
I looked in disbelief when my ping returned successful.
Thanks !!!
Having the same problem.. what fixed it for me was setting the system attribute. Run this command from an “Administrator: Command Prompt”:
ATTRIB +S %SystemRoot%\System32\drivers\etc\hosts
Thanks mi amigo! Only one solution that worked for me!
Lol @ the adobe line… never seen that before. ;) But thanks for this – I have some servers that have a different IP in-network than what my DNS gives me, which points to the router, haha.
yeah,it worked,this is the only way work for me
why not just copy a hosts file from anothere computer after remove it’s read-only properties?
Does not work for me, unfortunately. Windows still ignores the hosts file.
One thing I noticed, in step 5 above:
“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.”
When I do this, Windows insists on saving the file with a .txt extension.
One thing that trip me up…
‘nslookup’ doesn’t look at the host file. So I *thought* the host file was being ignored but it wasn’t.
still doesn’t work for me :( it’s soooo annoying
win 7 pro 64bit
Yeah, I gave up…nothing seemed to work for me either
Win 7 pro 64bit
The real solution is to open a command window in Supervisor mode and run
ipconfig /flushdns
after you have updated the file.
This clears the DNS cache and forces the system to use the new hosts file instead of its cached version.
I keep several versions of the hosts file on my system. I have batch files that rename them as needed and run the above line. On Win 7, I just have to remember to run it in Sup mode.
Just upgraded to Windows 7 Enterprise. Performed all the steps here (several times over just to be sure). Ping times out every single time–no luck. Suggestions?
Actually I’m not sure deleting files is necessary.
For me the step that got it working was pinging from the command line. This seemed to flush whatever needed flushing.
I have been told that if you edit the hosts file, you must always place the cursor on the last line and press enter then save it
I followed the steps and deleted the hosts orginal file but the new one will only save as a text file – help!
What I did, and it seems to work is this. I could not get the host file lost its attributes as a .txt file. I ran the cmd as admin and simply ran copy hosts.txt hosts then deleted the .txt file and it worked fine.
Can we just knock off the .txt on the file? That’s all the hosts file is – a text doc without the extension.
quoting Steverino:
Does not work for me, unfortunately. Windows still ignores the hosts file.
One thing I noticed, in step 5 above:
“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.”
When I do this, Windows insists on saving the file with a .txt extension.
Did you make sure that when you’re saving the new hosts file that it’s not saving with a .txt extension? Unless you make a point to select All Files (*.*) in the Save as type dropdown then Notepad will append .txt to the file you save by default. Even if you give it another extension, say “whatever.bat”, would be saved as “whatever.bat.txt” if All Files (*.*) isn’t selected.
Screenshot of the selection that needs to be made:
@ Kevin Souter
Yes, that is what I did, but it still appended the .txt extension. Renaming the file to “hosts” without the extension, keeps the file intact and it is working.
Make sure that you have the “Hide extensions of known file types” cleared in the folder option menu. Otherwise, when you save the file in Notepad, it will automatically append the .txt file extension and you will never know it. A hosts file with a .txt extension will be ignored by the system.
This is correct, although if you make sure to select “All files (*.*)” in the “Save as type” dropdown when saving the file with Notepad then it shouldn’t be an issue and the file will save without any extension, which is what you want.
I need help doing:
“I missed the opt-in for migration from the Yahoo! Delicious and now can’t find my account. What do I do?.
To those interested in accessing your old data, there’s a trick. You can edit your hosts file and add the following entries to it:”
98.139.50.166 http://www.delicious.com
76.13.6.190 secure.delicious.com
76.13.6.209 static.delicious.com
thank god! thank you so much problem solved.
I got it working, but hit a few minor bumps:
Although I did change the txt to allfiles, I didn’t use the quotations, so it still saved as a text until I resaved it yet again – this time with the quotes; so many sites say to paste something “without the quotes” that it’s second nature, oops LOL.
My ping of adobe failed also, but the hosts file I’m using didn’t have adobe in it, duh! So after I copied one of the blocked sites from the hosts I’m using, perfection!
Thanks!!
theres a way to edit the hosts file within command prompt it was my solution to this problem but now that im on a new system i dont remember how it was to do that -_-
Hello Kevin,
I really need help. I am using Windows 7 Ultimate x64 and I can’t find the host file on the system32/drivers/etc folder. It only have hosts.bak and if I edit it to ignore a host, it doesn’t work. Please help!
Thanks a lot!
Guys,
I log to win 7 but I try to save changes inside the hostfile but the system tell me that I dont have permissions although am adminstrator….?????
plz help me
Guys,
I log to win 7 but I try to save changes inside the hostfile but the system tell me that I dont have permissions although am adminstrator….?????
plz help me
And always remember to backup your Hosts file.
…just in case you make a mistake somewhere along the way
thanks a lot ! I have had the same problem, the hosts file work now (on windows seven)
Very timely post, I have been having this issue for a few days now and finally got round to trying to fix it, this worked!
Many Thanks
Roger
Thank you! It worked. That’s just crazy.
thanks a lot. Regarding the hosts file. It usually contains the “example” line you used above adobe.activate.com 127.0.0.1 and a list of other lines related to adobe as well. Is that 1 line enough or i need to use the long hosts i’m finding all over the net? I’m using CS5 and 4 at the same time. plz help