Home » Tutorials » Windows 7 Hosts File Ignored

Windows 7 Hosts File Ignored

windows 7Windows 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:

How to Open Notepad as an administrator in Windows 7

How to Open Notepad as an administrator in Windows 7

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.

Windows 7 Hosts File Doesn't Work

Windows 7 Hosts File Doesn’t Work

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.

On a side note, you may be interested in the SmartPCFixer, which fixes windows errors and optimizes your computer.  SmartPCFixer identifies your PC problem(s) in around 2 minutes. SmartPCFixer also increases your PCs speed, performance, improve startup times and improve stability.  Check them out.

  • Betty

    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!

  • Will

    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! :)

  • James Andersen

    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.

  • http://www.hipgeo.com Scott Daniel

    We only wasted two hours instead of eight. You are a god. Thank-you.

  • http://www.pickmywebbedbrain.net Ashley Shelnutt

    WOW! This simple step FINALLY allowed me to see my development site. Thanks for taking the time to write this!

  • Dave

    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

  • hamid

    I’ve been struggling with this for weeks.
    thanks so much. it works now. :)

  • Josh

    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!

  • sam

    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

  • suhail

    Thanks man .. it worked like a charm, so solved my oldest problem on windows 7 ::)

  • Steve

    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?

  • Nikos

    Hello guys,i did what you said but i still have the same problem!!!

  • Bryan Elliott

    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.

  • Carl

    The use of the HOSTS file is also affected by whether or not the Windows 7 machine is a member of a domain.

  • crolma

    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!

  • Steve

    Tried the above and the ‘ping’ does not show 127.0.0.1 as you mentioned

  • Scott

    Works great. Thanks for sharing! I’m happy to let the mystery be as long as I can fix it.

  • Bob

    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 !!!

  • Don

    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

  • Defonch

    Thanks mi amigo! Only one solution that worked for me!

  • http://cosplaysharing.wordpress.com/ Ashley Cosplay Blogger

    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.

  • ares

    yeah,it worked,this is the only way work for me

  • http://localhost/ karl

    why not just copy a hosts file from anothere computer after remove it’s read-only properties?

  • 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.

  • ralph

    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.

  • stylinred

    still doesn’t work for me :( it’s soooo annoying
    win 7 pro 64bit

  • Dave

    Yeah, I gave up…nothing seemed to work for me either
    Win 7 pro 64bit

  • Dan

    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.

  • Feediver

    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?

  • Mark

    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.

  • Marty

    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

  • Alison

    I followed the steps and deleted the hosts orginal file but the new one will only save as a text file – help!

  • Mrhooper

    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.

  • LMB

    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.

  • http://www.tweaksforgeeks.com Kevin Souter

    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:

    How to save the Windows 7 HOSTS file without a file extension

  • LMB

    @ 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.

  • Dan

    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.

  • http://www.tweaksforgeeks.com Kevin Souter

    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.

  • CBerger

    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

  • http://www.ln46c750.net/ mike

    thank god! thank you so much problem solved.

  • Shreela

    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!!

  • stylinred

    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 -_-

  • Pingback: How to block malware with the hosts file « Doug Vitale Tech Blog

  • http://coloredtexts.wordpress.com/ Henry

    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!

  • Aleksandra

    Thanks a lot!

  • Omar

    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

  • Omar

    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

  • http://superelitegames.com/ SuperEliteGames

    And always remember to backup your Hosts file.
    …just in case you make a mistake somewhere along the way

  • oblab

    thanks a lot ! I have had the same problem, the hosts file work now (on windows seven)

  • http://www.rogerperkin.co.uk Roger Perkin

    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

  • http://www.promenademarket.com Brian

    Thank you! It worked. That’s just crazy.

  • R

    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

  • Josch

    I had following lines in the hostfile
    192.168.11.11 wiki, wiki.testdomain

    turned out, I could not “ping wiki”, even after your tipp

    But I could “Ping wiki.testdomain”.

    So I changed the lines to

    192.168.11.11 wiki.testdomain
    192.168.11.11 wiki

    now both work

  • Pingback: Why doesn't my HOSTS file redirect DNS in Windows 7?

  • Andrew

    erm, weird i dont have a ETC folder in my drivers folder and not HOSTS file at all.

  • realpits

    Thanks that workeD like a HELL ! u have a beer from me :P

  • Damien

    Thank you this has been a big help

  • http://www.ptbmarketing.net Blake Waddill

    This has been driving me nuts for the last 2 hours. thanks!

  • Yann

    Thank you thank you thank you!

  • Teffy

    Thank you Don!!! Your system attribute tweak was also required on my system.

    Run this command from an “Administrator: Command Prompt”:
    ATTRIB +S %SystemRoot%\System32\drivers\etc\hosts

  • XRiera

    THANK YOU!!!! SENSEI!!

  • vietbt

    thanks……………

  • http://www.kbos2.co.uk/ Kevin Blumer

    The hosts file can sometime’s be a bit of a pain. the worst i have had it is where you can’t delete it but found a way round that as well just use a shredder that seems to do the trick.

  • http://www.mitprof.com John Ernest

    This is the problem with Windows. There are a lot of bugs that even their own updates to supposedly fix these bugs actually have problems. It would have been better though because of the number of resources.

  • unniw

    @Crolma above was key to making my file work. Thank you so much! XOXOXO!!!

  • Mark

    I have tweaked the hosts file and all but one of the entries are working, when i ping the address it picks up the correct IP but doesnt display the correct site any ideas?

  • http://www.totorotimes.com Jordy • Totoro Times

    “ping activate.adobe.com” -> Hahaha. So that is why it is used for :p

    I suspect it’s related to encoding. When using Notepad, by default, it uses ANSI…

  • martin

    thanx very much

  • Andy

    Hey I did this, worked, then a few days later stopped again.
    So make sure you check. I thought it was Search and Destroy Spyware software, but that is uninstalled now and it still keeps going back to ignoring it.

  • Johnny Funder

    My problem is a little different. In XP I used to have an entry in the host file like this:

    10.0.1.20 admin tech met

    which could access 3 different virtual web-servers on the same IP. Worked fine under XP, but Win7 seems not to read the hosts file at all.

  • KC

    I stuggled a lot with this. What solved it for me was to just clicking on the hosts file name in the etc folder and deleting the extension (kind of renaming the file). The system would complain that the file would be unusable but just ignore it.

  • Irvin Sorzano

    This is great, just exactly what I needed to learn

  • JMD

    I was able to ping my localhost which worked but I was unable to access it through my browser (chrome).

    Strangely enough it worked in Firefox, so I guess chrome is caching it somehow.

    I presume it will work in chrome as well once I restart my computer.

  • DumbArticle

    This article is inaccurate. It has nothing to do with Windows 7 or with deleting/saving.

    It is because you have to provide a line terminator to every line. As long as you have a blank line at the end of the document, it will work fine (and has ALWAYS been the case).

    I bet, anyone at stack could have given this a correct answer. Instead you write a garbage article, don’t understand the problem, and try to gain some ad revenue.

    lol.

  • ouflak

    Ok, saw something very odd when doing this. Normally I edit the hosts file with Wordpad, and this has worked perfectly no problem for literally years. Then, I noticed that the hosts file was being ignored. Having bounce my head off a few other reasonable suggestions, I tried this and saw something very odd. When I opened up the hosts file with Notepad I saw that every line had “\par” appended to it. Also, the top line had a path in brackets on top. Quite obviously the file had become corrupted in some way that Wordpad couldn’t see. Deleting the weird path and all of the “\par” appendices did it.

  • jilani

    Awesome ! Thank you for such wonderful tip

  • LGM

    THANK YOU THANK YOU

    I am still sane in spite of MS! Another day of my life wasted. Microsoft has wasted more of my life than any other cause.

  • http://www.tweaksforgeeks.com Kevin Souter

    I have to disagree. I actually tried StackOverflow when I first had the issue, tried adding the carriage return to each line manually, etc and it didn’t work. Also tried using one space between the url and ip, a tab between, etc with no luck. It wasn’t until I completely deleted the file [after copying the contents] and then re-saved it as a new file that it functioned. If it’s a terminator issue, then explain why deleting the file and then pasting in the EXACT SAME contents then works. I’d actually love a legit explanation to why this happens.

  • GROAT

    I had to DELETE THE TXT EXTENSION via window explorer. It then worked perfectly!!

  • http://www.ilnullatore.altervista.org Simone

    Thank you, thank you, thank you!!!
    Now my soul is free!!! XD

  • Wildeman13

    Edit the hosts file in notepad as Administrator. Highlight the white space between each IP and hostname and replace it with a or two. Just get the characters out of there. This fixed it for me and I was at the point of throwing my PC against the wall after trying everything else and nothing fixing this issue for me.

  • Wildeman13

    Silly text box formatting… replace the (SPACE) characters with a (TAB) or two is what that should read as.

  • reynodan

    Thank you DumbArticle. I couldn’t get my hosts file to work properly. I did not know about the blank line requirement at the end of the hosts file. All I did was add the blank line and it worked great.

  • Midz

    EXCELLENT

  • peterr

    After trying many different suggested solutions, I checked the security on the ‘etc’ folder and compared its permissions to that of the ‘es-ES’ folder, and found that the group Users did not have Read & execute rights like they did on the other. After taking ownership (again) of the ‘etc’ folder, I granted group Users Read & execute permissions, and had them inherited by the folder contents. That fixed the problem for me–whatever part of the system queries the hosts file evidently is under the restrictions of the User group. I must have removed the group’s permissions accidentally at some point when trying to modify the hosts file.

  • kris

    open a cmd prompt, navigate to the hosts file directory. type “dir” and you see hosts.txt. type “rename hosts.txt hosts” and hit enter. Then do an ipconfig /flushdns.

  • UnsUwe

    great Work!
    I spend 2 Days with searching why windows doesn’t get the entries in the hosts-file.

  • John Aholic

    even changing the pull down on bottom to all files it still saves as hosts.txt n you need to remove the .txt ‘weird is one time it did save without extention but next it didnt and ;i redid again n for sure pulled down to all files but it added txt anyway

  • http://sadgeeksinsnow.blogspot.com Ken

    So, I believe I have discovered the root cause of this bug.

    At least in my case (but I imagine *many* others too) it’s an encoding issue.

    http://sadgeeksinsnow.blogspot.com/2013/02/when-windows-hosts-files-stop-working.html

    tl;dr. Your text editor uses Unicode/saves as Unicode. Windows expects ASCII – ensure your output encoding is set to ASCII.

  • kcrane

    Thanks, that worked…

  • Megan

    Corruption in the hosts file? You’ve been on a Mac for too long.

  • http://www.3cdelhione-noida.com/ indiarealtyedge

    thanku..to give me detail for host file.

  • Tonagon

    I just ran into this in WIndows 2003 server.
    After reading this post I took a look at my hosts file through vi (I cygwin running a Unix shell on the server) and while I still could not see what was wrong with the file it did tell me at the bottom that the file was incomplete. Somehow it was corrupted.
    I recreated a new one, ran ipconfig /flushdns and tried pinging my desired host and finally got back the correct IP!

  • Jason W

    What happened for me was the permissions on the HOSTS file itself. It did not include “Users:Read” or “Everyone:Read”. This occurred because I had made a copy of the HOSTS file in another directory, edited it, then copied it back. When I copied it back (from my elevated command prompt), it was created with permissions such that only Administrators could read it.

    It may be that since you saved the file with a non-elevated Notepad window that the permissions included Users or Everyone.

  • Ian

    to make it nice and simple…open existing hosts file with notepad, make required changes, save to your desktop (or elsewhere) as “hosts.txt” (without quotation marks). Delete (or rename existing hosts file in windows/systems32/drivers/etc) and copy new hosts file from where you saved it. Change file name from “hosts.txt” to “hosts”. Note that you will need to in your administrator login in order to perform above steps. Takes about 2 mins… :)

  • luhuiya

    you are amazzingggg
    god

  • aniruddha

    I was struggling with all the given solutions thanks a ton for your valuable advise

  • http://olly.im Olly

    Either this worked, or the commenter about registering it as a system file worked – either way i’m back with a working hosts file! Many thanks!

  • http://www.org/ Bob Bobson

    Of course “activate.adobe.com 127.0.0.1” won’t work, you have it backwards; the IP address must *precede* the domain name:

    127.0.0.1 activate.adobe.com

  • Pingback: What can cause a DNS lookup to ignore a hosts file entry? - Just just easy answers

  • http://www.tweaksforgeeks.com Kevin Souter

    You are absolutely correct good sir, I must have accidentally typed it in backwards when writing the article. Thanks for pointing out the error it has now been corrected.

  • Pingback: Windows ignores the hosts file « prgmr.io

  • John

    Thanks, this worked correctly. Thanks

  • Shahid

    Finally got it working on Vista. Most likely, the resolution was to do saving the file using ANSI encoding. Thanks a lot.