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 for the tip! This saved me lots of time and stopped me from swearing off Windows once again.

  2. I edite host file but not work


    is not work

    i need this site block this site but noting

  3. It worked for me! Had to test working of newly transferred wordpress blog and couldn’t edit host file. A google search rendered this article and I am so glad that it did :)

  4. i need to redirect facebook to google
    i tried so much but didnt work
    i am using win 7


  5. 1. Find the hosts file ie. c\windows\sytem32\drivers\etc and opend the hosts file with notepad. Ctrl+A to select all the text then Ctrl+C to copy all the text to the clip board then close the hosts file. You haven’t made any changes at this stage so you won’t be prompted to save the file.
    2. Right click on your notepad programme and choose run as administrator.
    3. When note pad opens in admin mode you then copy the hosts file into notepad ie Ctrl+v to paste then Ctrl+S to save. The window should open giving you the opportunity to save as a .txt file but click on the down arrow and choose “all file types” then choose save in the same directory as the hosts file.
    4. You will be told that the file already exists and would you like to replace it with the one that you have copied and presumably edited, choose yes and A MESSAGE SAYS: THE PROCESS CANNOT ACCESS THE FILE BECAUSE IT IS BEING USED BY ANOTHER PROCESS!!!!
    using windows 7 64-bit
    please help

  6. Thank you! It solved my problem in one try. Once again, thank you.


  8. Ah, I forgot to check the .txt extension on my hosts file. I had one and that is why is wasn’t working. Now, I am all set. Thx for the post! –Richard

  9. hiiiiiiiiiiiiiiiiiiiiiii,

    a big thanks to u

  10. I do it this way:

    1. Copy hosts file to your desktop,
    2. edit it with Notepad++ and just click Save
    3. replace the old one in etc folder with the new one from your desktop.

  11. Thanks alot

  12. I tried everything and nothing until I take dhiraj advice THANKS man you rock

  13. Obviously, it is NOT as easy as AKSHAY’s post, or people wouldn’t be posting for more help over and over, so WHY do you keep repeating how easy it is? Please it is NOT that easy, at least not with AMD, on my win 7 it does not even have the file that was posted above! The only hosts file says, “sample only” >> downloading take ownership app, any other advice?

  14. thanks! its worked :)

  15. This helped me save me time and is perfect.

  16. Thank you so much for the video instuction on how to edit the host file on vista. It made it so easy for me to get into my host file and delete all the IP’s that has been preventing me from signing into my hotmail account. What a great relief to finally get this over with after about 10 grueling days of less sleep and stress trying to figure out what is a host file, how to find it and edit it e.t.c. I am a computer illiterate, so this was a great learning experience for me despite all the troubles i went through, it is worth it. Thanks alot and God bless you.

  17. Great !!!

  18. thamk u

  19. Editing (and implementing) my hosts file only leads me to believe my DNS is hosed. Thanks for the information.

  20. i cannot configure it, i did it but i m not sure it is right

  21. I’m stuck with the most stupid problem ever !
    the original hosts file won’t let me unmarke “read only” an error window pops up saying:

    an error occurred applying attributes to the file :

    access denied

    Now , I made a copy of the hosts file and edited it with your method just fine
    ( the copy wasn’t marked “read only” to begin with )
    but I can’t remove , rename , or replace the original with the edited copy

    what to do ?

  22. thank you very much!! ><

  23. when i try to run notepad as administrator i getting the error -unable to logon, logon failure.uer account restriction.possible reasons are blank passwords not allowed, logon hour retriction has been ennforced. why! please help me

  24. I have successfully edited my host file, but every time I log in from a different wireless server my changes are lost, and I have to edit it over and over again. Why is that happening and how can I prevent it?

  25. That Run as Notepad option also not worked for me ,In Safe Mode We can able to edit the host file ,Checked it was working for me

  26. thank you very much
    i weast my half day time to solve the problem.
    finally reading one of these comments, on hosts right click property and untick read only. problem solved.

  27. This worked a treat. Thanks for posting as I could not find this file anywhere!

  28. Thank you :) I always forget admin privileges required to edit these files.

  29. Thanx…!

  30. Hi I had the same problem but I beat it by running pc in safe mode with administrator rights and just copy and paste over old host file…Before I kept getting the prompt other programs are using this file…

  31. Running notepad as administrator worked for me as far as saving the hosts file goes, but win 7 would still not resolve anything out of the hosts file.
    That is Until I connected one network card on the pc to a network, then it started reading the hosts file all of a sudden. So looks like windows 7 needs an Active network card before it will start looking in the hosts file.

  32. I was at the point of dumping a project when I found this, thanks it helped.

  33. Thanks for the info. I’ve never had to worry about this file type until today- thanks for the help.

  34. Another way to do this is to right click the hosts file and select properties. Then untick read only. Then it can be opened, edited and saved, providing the file is not in use. If it is in use, you can save to your desktop and then delete the hosts file, replacing it with the one you saved to your desktop.
    I agree with other commenter’s, this is entirely insane. I am the admin of the PC, why can’t I change the hosts file as I could with XP? Microsoft, please quit assuming we are all idiots.

  35. Just goto properties and in security tab add “everyone” and allow al permissions and save settings…u r done :)

  36. Thank you! It is odd to consider that there might be solutions to _many_ MS Win problems.

  37. This worked better than I expected Many Thanks.

  38. I have made a huge mistake by rightclicking on a file called “HOSTNAME” in Windows 7 in C:\windows\system32\HOSTNAME and then selecting open with note pad.

    Now all applications such as Google chrome, Skype, etc are not working and when I click on them notepad opens with some weird computer language!! Any ideas?

  39. Really must read page

  40. When I opened NotePad as indicated (in Windows 7 Home Premium SP1), and navigated to …/drivers/etc, at first I did not see any files. Then, Duh, I saw that the filetype was defaulted to ‘.TXT’. Changed that to ‘All Files (*.*)’ and whereupon the hosts file showed up. I added my subdomains for localhost, did File > Save, and immediately WampServer was happy with api.localhost and the others I had added. It is important to start NotePad with the right click > Run as Admin option; the rest (other than selecting ‘All (*.)’ extensions) was business as usual. Thanks!

  41. Thank you.

  42. Your ROCK man!
    You should be the CIO of some MS branch or something…
    Great tip, thank you.


  43. @amit – I wouldn’t make your hosts file available to everyone; it’s a common target for viruses and other malware. They can replace a link to (say) your internet bank with one to their own copy site, and the URL in the browser would look fine; you’d know nothing until your payment started bouncing.

    Those who commented about it being a “SAMPLE” file- yes, until you add stuff, it only has one entry, which equates “localhost” to

    What I’ve done is to add a shortcut that contains
    “notepad c:\windows\system32\drivers\etc\hosts” as the target (without the quotes).

    When I need to edit it, I right-click on the shortcut and select “run as administrator” – even if you’re already logged in as admin, you need this “elevation” to trigger the UAC challenge, which scripted tasks can’t pass.

    Oh, and those who have a fancy path on X64 system – that’s directed via winsxs system (Windows side-by-side) which allows 32-bit and 64-bit to co-exist; if you resolve the path, it’s actually pointing to the same file as the one in System32.

  44. look, ive been on the admin profile on my computer and my normal one. i am the ONLY USER to this computer and i try everything ive been at this for 46 hours straight. EVERY time i go to save it it tells me my hosts file is set to ready only. so when i go to change it it wont let me saying i need to be an adin.

    i went on to the REAL admin profile (witch is a hidden profile on your computer) and it STILL wont let me change it from a ready only file. i NEED HELP ASAP PLEASE!!!!!!!!!!!!

    ill love you forevers!

  45. For you Notepad++ users the “Run As” method won’t work. For some reason when you browse to the C:\Windows\system32\drivers folder the ‘etc’ folder is not displayed and thus you can’t get to the hosts file. Weird. And if you start NotePad++ in Run As mode and then try to open hosts from Windows explorer the file does not open. Looks like running standard Notepad in ‘Run As Admin’ mode is the only way to edit.

  46. you nailed it perfectly, thank you so much!!

  47. copy hosts-file to desktop from “%systemroot%\system32\drivers\etc”.
    edit hosts-file on desktop and add these lines before save:
    #pass WGA-check in windows xp pro corp. mpa.one.microsoft.com
    # Pass OGA-check for Office 2007 sls.microsoft.com
    # not sure yet activation.microsoft.com

    now copy hosts-file from desktop to:

    (%systemroot% = “c:\windows” most of the times)

    admin-rights required !!!

  48. i tried this but when i open from notepad menu and goes to the location of my host file i finds nothing.. but if i go their directly via my computer the files are there..

    HELP.. :(

  49. thank you for your help with this. it worked great

  50. THANKS A LOT!!! It did the trick. Been thinking ages why I can’t edit ‘HOSTS’ and your tip worked.

 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>