Jan 212009

This may sound silly suggestion to even post on Windows Reference but will help avoid some annoyance with Windows Vista and Windows 7. The host file is the one where one enters hostname and IP Address pair manually as against being served by a Name server (ex: DNS). As always the “host” file is under C:\windows\system32\drivers\etc\ or %systemroot%\system32\drivers\etc\ and hence cannot be edited by normal users.

To edit the host file,

Click Start – search for “Notepad“, right-click and select “Run as Administrator“. This should launch notepad with elevated privileges. Now, open the host file from the File menu, edit and save.

This should help!!!


Windows 7 Essential Training – Free Video Training Tutorials

Incoming search terms:

  250 Responses to “Edit hosts file in Windows 7 & Windows Vista”

  1. thanks you very much.its worked.

  2. Good one. Saved my time ! Worked as said. Great !

  3. Thanks for the fix btw. Actually worked! But I am curious why this is still an issue with Google, considering the original post was back in early 2009?

  4. thanks you very very much.its worked.

  5. thanks man… internet rocks!

  6. I want to say that if you have any anti-virus installed in computer. It may lock host file cause that you can’t change host file even with administrator permision. So disable anti-virus then do like this article.

  7. god bless u thax sooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo mutch

  8. I have tried but host file is nowhere to be found. I am running as administrator. It didn’t work so I disabled antivirus. Still cant find the file. I filtered it to all files instead of text files.

    I have found hostname file and ihost but these are exe files and when opened in notepad there obviously scrambled code. Can anyone help? Thanks.

  9. So I can’t run my ACTUAL host file, because it continually shows up as a sample host no matter what I do. I’m running as Admin, I tried to open the file directly from notepad and I’ve read EVERY SINGLE COMMENT HERE and I’m still having the problem! How the heck do I get it to quit showing me the stupid sample file?! Please help, without my Google websites I don’t have access to my main email and my important documents ): also I’m running Chrome, dunno if that has anything to do with any of this.

  10. The problem I was having why it wasn’t working was because I had my antivirus enabled. If you are still having problems, try disabling your antivirus.

  11. Simple and well explained..to the point. Well done!

  12. Awesome & Superb Trick. It helped me a lot. Thank you.

  13. I swear thanks you sooooooooo much!

  14. the reason you have to run as the administrator Is because with windows vista and 7 your account is not truly the admin its a security thing but can easily be enabled just do a quick google search on how to enable the hidden administrator account . All thought its not recommended as I said security reasons good to know how to enable it thought if you ever get hit with a bad virus they shouldn’t effect the admin account since its not active……. The more you kno

  15. Glad I found your post, spent the afternoon struggling with this. You would think MS would put this in the Help file. Thanks again.

  16. nice tips, thanks alot


  18. Worked. Thanks!

  19. A word to a wise

    thanks man

  20. I am at my wit’s end – my hosts file is infected somehow (igoogle and random ad servers will redirect me to adware sites), but every single virus scan i’ve tried comes up totally clean and my only option appears to be editing the hosts file. Hijackthis is utterly useless, as the file has been blocked as read-only – and here comes the infuriating part.

    The problem is, no matter what I do, I can’t disable the hidden and read-only status of the file! Every time I uncheck “read only” in the etc folder then hit apply, I get an error window – “You will need administrator permission to change these attributes. Click Continue to complete this operation”. I *am* the administrator, and click continue (with the little admin logo next to it), but this does absolutely nothing and the folder/files still remain read-only. I can open the file in notepad and delete the bad entries, but I can’t actually save it because (surprise) it’s read-only.

    Not like I can fix it right now anyway and i’m not sure if it’s relevant, but here are the bad entries in question: http://www.google-analytics.com. ad-emea.doubleclick.net. http://www.statcounter.com. http://www.google-analytics.com. ad-emea.doubleclick.net. http://www.statcounter.com.

  21. Thank you very much


  22. Thanks a million! Such a great tip!

  23. Those of who failed to modify the hosts file, try and take ownership of the file (Properties >> Security >> Advanced >> Owner >> Edit) or see the microsoft support site on how to change ownership. Once you own the file, give yourself or your group write permissions, and then modify the file.

  24. thanks alot…..now i get how to edit hosts file
    keep learn people//

  25. Tanx a tonne 4 de post it’s actually working..yuppie finally i done it..:)

  26. Thanks so much for posting this.

    screw all the others tips i read and most of all screw you windows permissions!!

  28. check antivirus, maybe antivirus or other program block u from changing ur host file like mine..i m using antivir antivirus, it block me to change my hosts file..

  29. The very first answer in this posting answers the question how to edit the hosts file with just one minor addition: When the message says “No items match your search” You need to simply Change file type from .txt to All Files (“.”)
    After wasting a few hours, I found that this combination works every time, and only takes a few minutes.
    There are many helpful comments in this posting, including the hint to change file type. Thanks for all of your help.

  30. Here is the solution which works, with minor adjustments to the great work previously proposed by by winsockfix and badbob117.

    First check that the ‘hosts’ file exists in the path:

    Alternatively, to get there more quickly, you can ‘search programs and files’ for %systemroot%\system32\drivers\etc\

    If you cannot see any files within the ‘etc’ folder, you may get a message such as ‘No items match your search.’ Don’t panic, Simply change the file type to All Files “.”

    Even if the ‘hosts’ file does not exist, don’t worry. Just get to the ‘etc’ folder because you can save a ‘hosts’ file, which you create, in that folder.
    Usually, the ‘hosts’ file will already exist.

    If it already exists, within ‘START,’ search programs and files for ‘Notepad,’ then RIGHT CLICK and choose ‘Run as administrator’

    Now navigate to the ‘hosts’ file using the path mentioned above.
    Open the file and add a new line within the file, where you will enter IP Address and hostname, separated by at least two spaces on the same line.

    Save the file. If the resulting file saved is named ‘hosts.txt’, rename it to ‘hosts’
    since there should be no extension.

    THATS ALL that is required and it truly only takes a few minutes.
    You do not need to change the properties of the ‘hosts’ file because you set Notepad to ‘run as administrator’ earlier. < < <

    HISTORY and acknowledgments to WINSOCKFIX and BADBOB117
    I had experienced frustrations too including messages such as 'An error occurred applying attributes to the file' and 'No items match your search' and many others reported by administrators concerned that full administrative rights had been removed and that they only had 'read access' to the hosts file if they could even find that file.

    The original posting by Winsockfix to which there had been 226 comments, many of which express frustration, and even unneccessary suggestions to change file permissions within file properties was the most helpful. There has been much venting about Microsoft and concern that full adminstrative rights have been removed.

    All of this is so unneccesary, as I tried many of the suggestions and finally discovered that small adjustments to the original (March 2009) posting by winsockfix worked, using PART of a minor addition proposed by badbob117 in October, 2009.

    • Hello Roblyn,

      I followed exact your instructions but after the change to host file then I tried to save it, it was saved as host.txt. And then when I removed the file extension .txt, the error came up “this file is read only”.

    • None of the suggestions in this forum helped. As has been suggested there is the case where the hosts file is a mere “sample” and changing it is a waste of time. I have a Claro search engine on my computer[does not show in any files] and have tried one and all of the suggestions given but not one has worked. I have my homepage set in my internet options but when I open Firefox it still shows Claro search engine. I have changed the listings in about:config and they still revert to the Claro settings.
      Boil it all down and it just another proof that Windows [after 3.3} has been crap…………sorry expensive crap. Many of the restrictions imposed by MS are totally unnecessary. So it looks as if I am going to have to carry out a re-install – but then who long before this Claro rubbish, or some other, is going to install itself unbidden and unwanted on my machine?

  31. You helped me so much people!! You are amazing!!

  32. THanku so much really it worked good thank u again.

  33. It worked and i say Bravo !

  34. Heres what you do if you can’t change your hosts file:
    1. Open it up with notepad
    2. Remove the offending IP’s
    3. Save to your desktop
    4. Delete the file from your system32 (need administrator)
    5. Place the one you saved on your desktop back inside (without the bad IP’s)
    6. Should be finished.

  35. an easy way is simply copy hosts to desktop,edit in notepad,save then drag and drop into hosts no admin or take ownership bang bang

  36. what is all the story after the original post.Just say that’s the perfect solution period.cause it works like charm…..kapich?

  37. worked awesome! thanks

  38. nice post, Glad I found your post, spent the afternoon struggling with this. You would think MS would put this in the Help file. Thanks again.

  39. Dose not work for me at all.

    I run note pad as administrator – still get access denied.
    I can not change ownership or permissions of the file or the folder, even when antivirus is turned off.
    Even running in safe mode did not help.

  40. Shift + Enter + Click on Notepad++

    works even greater :)

  41. thanks mate :)

  42. thanks. it worked.

  43. Guys if you have problems even running notepad as administrator check out the antivirus, becasue is possible they block access to system files like this, I had to disable a moment the realtime protection of antivir to edit the host file

  44. I have a doubt, why editing host file when we can add restricted sites in IE under Tool>Option>Security?

  45. Hi
    before opening HOSTS file in notepad ,Should right click on the file and untick “READONLY” and apply. If we do not, can be saved as text file.

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>