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

Sponsored:

Windows 7 Essential Training – Free Video Training Tutorials

Incoming search terms:

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

  1. Windows 7 Ultimate –
    1 – Located Notepad
    2 – chose run as administrator
    3 – pasted location of hosts file which is impossible to type by hand since it is a huge path on 64 bit systems (NOT windows/system32 on 64 bit)
    4 – edited hosts file as needed
    5 – SAVE – logged in as admin and opened Notepad as admin – still I do not have permission to save this file.

    I’ve worked on Linux and Windows since mid 90s and have always been able to edit the hosts file without problem, until now.
    Way to go MS – another insanely stupid idea – let’s take away file editing privileges from logged in Administrators!

  2. I also am using Win7x64 and in order to finally make changes to and save my host file I needed to go to properties of the folder AND the file and take ownership of them. What a PITA.

    Under Security, Advanced, Owner both the folder and the file were owned bt SYSTEM – changing to Admin/MyName produced a sequence of errors, but eventually it changed – again – what a PITA.

    Finally achieved my ends, but now I cannot revert the ownerships to SYSTEM – I bloody well hope that doesn’t screw my system up.

    Thx MS for making this task so nearly impossible.

  3. Thanks for the question and answer! I was wondering how come I couldn’t edit it.

  4. Great!So easy and save my time!!!Thanks a lot!!!

  5. thanks mate.. It works charm

  6. Thanks a lot! Very good instructions.

  7. We have two boxes with Win7 Ultimate. The ‘Notepad run as administrator, open the hosts file, modify, and save’ trick used to work at least as recent as July 2010. It doesn’t work any longer, and I don’t want to take ownership from system. A windows update problem perhaps?

    What does work for me is:
    -Run Notepad as administrator
    -Open the hosts file and modify as needed
    -Save the hosts file under a different name
    -Use explorer or cmd to change the name of the original hosts file
    -Rename the newly created file to hosts

    I don’t know what has changed and why the simple solution no longer works for our environment.

  8. Thanks for posting this. Saved me a lot of time!!

  9. Hi
    solution for those who cannot edit hosts file with above mentioned solutions. (even in safe mode cant do a thing, eveything is protected, even when iam admistrator)i have w7 64. my hosts file is under windows/winsxs/amd64 etc ( you know where).
    it took me maybe 1,5 hour to find it. so ill share it with you.
    http://www.sevenforums.com/tutorials/1911-take-ownership-shortcut.html?ltr=T

    go there and download a small zip file with reg files Add_Take_Ownership and Remove_Take_Ownership.
    Thats it. just run Add_Take_Ownership.reg then richt click on hosts, take ownership a edit. you can then use Remove_Take_Ownership.reg a everything is back as it was

    Hope to save your time a nerves :)
    Thanks for people with brain to help us with out it

  10. Nice, works fine here! Thank you!

  11. Thanks much, I anticipate this will work!

  12. Thank you Zia Shaikh for a solution that worked.

  13. Never have I seen such a resounding apreciation!
    To which I add ‘Thanks dude!’

  14. !!!!!!! thank you !!!!!

    Mike,
    Transilvania.

  15. just wants to say this worked ! thanks a lot :)

  16. it took me almost an hour to figure out why it wasnt working. check your antivirus to make sure its not locking the file. i know avira does.

  17. Thanks a lot for the tip!!!

  18. Thanks. Works like a charm, together with ‘block content’ in Opera. Advertising is fine as long as we look it up voluntarily. The right-in-your-face attitude kills the beauty of the internet.

  19. Perfect — thank you!

  20. on Windows 7 , there is hidden directory etc\ in C:\Windows\system32\drivers\ … in this directory you will find hosts file … I can only edit this file logged as administrator ..

    hope it helps

  21. I forget .. I can also see that hidden \etc\ folder only as Administrator … logged as user from admin group, I can’t see that folder .. So try to do all changes as Administrator, and you will win over Windows ..

  22. Finally, I got the way to edit host file in Win7. After reading all the comments all over again, maybe I just report one way.

    1. Find your host file, right-click it, and click on ‘Properties’.
    2. If it says ‘Read-Only’, uncheck it and apply.
    3. Open your Notepad by right-click it, ‘Run As Administrator’.
    4. With the opened Notepad, File>Open>….find the host file.
    5. Edit and save..

    then You good to go.

  23. worked like a charm…great thanks

  24. thank youuuuuu!!!!!!

  25. p.S. LAST GUY has the right way . Dont forget to put back your host file in read only! Because some virus can tamper with it if its not in read only and you can even hide it, so your kids or other person cant tamper with it. :D

  26. thanks it really worked

  27. UPDATE: Edited the hosts file here: C:\Windows\winsxs\amd64_microsoft-windows-w..nfrastructure-other_31bf3856ad364e35_6.1.7100.0_none_d196965304ce3de

    :(

  28. Thanks you are a life saver <3

  29. Thanks I need This tutorial

  30. I’m using Windows 7 Home Premium 64-bit.

    The only host file(s) I’ve found in either directory,
    C:\Windows\System32\drivers\etc OR
    C:\Windows\winsxs\amd64_microsoft-windows-w..nfrastructure-other_31bf3856ad364e35_6.1.7100.0_none_d196965304ce3de

    are sample files!? My firewall is ZoneAlarm and, at the beginning (after installing Windows, then ZA) I had ZA lock the host file (I assume ZA ‘knew’ where the host file was/is) – - could that be why there are no other host file(s) other than the sample ones?

    Thanks in advance! :)

  31. 1. Click Start, click All Programs, click Accessories, right-click Notepad, and then click Run as administrator.If you are prompted for an administrator password or for a confirmation, type the password, or click Allow or Yes.

    2. Open the Hosts file or the Lmhosts file, make the necessary changes, and click Save on the File menu.

  32. I tried these steps, butw hen i go to etc then try and access my host file nothing is tehre like it no longer exists, how can i acces sthis?

  33. Thanks … it works perfectly

  34. Well just to clarify the situation. I’m running vista home premium 64bit and all I had to do to edit and save the hosts file was as follows:
    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 your done!!
    Hope this helps.

  35. Thanks for the hint.

  36. Worked great! thanks for the tip. for those who cant see the files select “all File Types” where it reads .txt text files.

    Thanks again!!

  37. thnxxxxxxxxxxxxxxx for help :)

  38. i cant edit my host file…it says “Compatibility modes cannot be set on this program because it is a part of this version of Windows”

    i am using win7 Pro SP1
    plz hlp…

  39. THANK YOU! THANK YOU! THANK YOU!

  40. i have tried everything but it still never works i need help please i am going crazy

  41. actually the comment Jeffrey Yong posted a couple messages back actually works.
    Thanks a lot you just made my day

  42. If you’ve made this far down and still cant get it then let me tell you what i did:

    1 – OPEN START MENU
    2- ALL PROGRAMS
    3- ACCESSORIES
    4- RIGHT-CLICK ON NOTEPAD
    5- SELECT RUN AS ADMINISTRATOR
    6- WHEN NOTEPAD IS OPEN, SELECT FILE MENU
    7- SELECT OPEN
    8- NAVIGATE TO HOSTS – C: WINDOWS/SYSTEMS32/DRIVERS/ETC
    9- ADD YOUR ENTERIES TO HOSTS FILE
    10- SELECT FILE MENU THEN SAVE
    11- JOB DONE

    honestly, it is very easy, once you’ve done it you’ll wonder what the hell you’ve been doing all this time.

  43. thankss dude…
    save my work today :)

  44. Thanks Great Help

  45. brilliant!

  46. Follow the instructions *exactly* as Akshay wrote. Also, thanks, everyone.

  47. thanks bro

  48. Thanks.

  49. Just copy “%systemroot%\system32\drivers\etc\hosts” into the open box and click open. Make the desired changes. Then save.

  50. very nice. thanks for sharing!

 Leave a Reply

(required)

(required)

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>