Windows 7 – Edit the Hosts File

Need to figure out how to edit the Hosts file in Windows 7? For the most part, it’s pretty much the same as Windows XP and Vista, but with a few extra hiccups!

Just if case you don’t know, the Hosts file is where you can manually enter a hostname and an IP address pair, thereby bypassing the DNS server. This can be pretty useful in certain situation, especially for anyone in IT.

The path to the Hosts file in Windows 7 is the same as usual:


where %systemroot% is usually c:\windows unless you installed Windows on a different partition. By default, you cannot see these hidden folders since they are system folders.

To show hidden folders in Windows 7, press the ALT key while in Explorer to bring up the File menu. Click on Tools and then Folder Options.

hosts file windows 7

Click on the View tab and then click on the Show hidden files, folders, and drives radio button under Hidden files and folders.

show hidden files windows 7

Now navigate to the directory above and open the hosts file and make your changes.

edit hosts file

Note that this method for editing the Hosts file will not work. You will get a message saying you do not have permission to save in this location.

windows 7 hosts file

In order to edit it, you have to click on Start, type in Notepad and then right-click on Notepad and choose Run as Administrator.

run as administrator

Now navigate to the drivers/etc folder again and make sure to choose All files for File Types otherwise you won’t see the Hosts file.

view all files

Make your changes to the Hosts file and click File and Save to save all changes. Now you will not get the error about not being able to modify the Hosts file. Enjoy!

Comments [53]

  1. It is not necessary to check "show hidden files and folders" because "hosts" is not a hidden file.

  2. going to the folders is quick enough. Being thorough and including more than what should be is good as well!!!

    it reminds you where to access hidden files, if you don't access them often :) thnx Aseem

  3. Nice addition to two other articles, ref:

    Seems odd that none of these tutorials/tips mention the default hosts file (as on my machine, I've never knowingly modified or even accessed) which currently reads much like a readme (saying the file is a sample file, plus I find no actual website entries to indicate any site is blocked).

    What are users to do (when manually adding blocked sites)? Maybe delete all the original text and then add sites?

  4. It works right up till the point where you save, and it still says I don't have permission to save. Everything is exactly where the process states. I found everything, clicked everything, but I'm not able to save. Help!

  5. Keep reading Ginger, it doesn't work unless you open Notepad the way it shows after the point you stopped.

  6. Tells me "access denied." Am I missing something?

  7. Yes, you need to take ownership of the file and give yourself full permission to modify the file. Once saved, then you revert it back to the attributes it had before you changed it, and revert ownership to the original owner. This is the only way to keep the file, because if you don't, windows will rewrite a new one to replace the one you just saved.

  8. Actually, in addition, it's because the file is marked read-only by default. You must right click -> select properties, and un-check read only.

  9. Thanks for the useful post. Solved my Problem. :)

  10. Hi.

    I have done everything that this thread has suggested, but I still keep getting a sample host file.

    Should I just paste my IP addresses underneath, delete the text, and paste them in? Or, is there a different thing I can try to find my real host file?

    Please help.

  11. Thanks, man! It really worked. ;-)

  12. I had done this many times in xp but was searching for modifying hosts file in Windows 7. Thx for the update I needed. Richard

  13. Hey guys,

    I have tried everthing to edit the file. I opend the notepad as admin or even activated the admin account to change the host… But whatever, it was worthless.

    Does someone have a new idea???

    Thax in advance

  14. Spybot S&D/symantec indicate that my hosts file has been altered. I tried to follow the instructions above, but am unable to locate the file in the system32driversetc folder (I do see the 4 other files: lmhosts.sam, networks, protocol, services). Is it possible to find the HOSTS file elsewhere?

  15. Just to say thank you sooooo much for this solution, …opening notepad as administrator. I spent three full hours with HP tech support in India with them finally telling me that I couldn’t edit my host file. I owe you a coffee next time I see you for sure…

  16. Hi

    I am trying to block a computer from Google Chat because all they do is Chat instead of working. Do I need to go through this and put in 127.0.01? Is there any easier way? I am not Tech savy.

  17. I can’t edit my host file for whatever reason. It’s not checked “read-only,” I’m running NotePad as an Administrator and opening the direct file and everything, but for whatever reason, it’s still a sample host file!! Please help me, I can’t access my main email and documents without Google sites (which are what aren’t opening; I use Chrome if that makes any difference).

  18. don't delete anything
    just add a line for the ipaddress that you want

    # localhost name resolution is handled within DNS itself.
    # localhost
    #::1 localhost

  19. The following additional steps may be required to make the above work. Find the hosts file in Explorer (don’t use the shortcut), right click its name, select ‘Properties’, click the ‘Security’ tab, click the Edit button, select the user that is assigned to you, check the ‘Allow’ checkbox of ‘Full Control’ and click OK until you exit. There is no need to reboot.

  20. I tried to elevate the both notepad and cmd but still no luck, so I edited the host file from safe mode, it works perfectly.

  21. Microsoft does it again. Preventing you permissions to edit files on your own computer. This is part of why I upgraded from Vista to XP when I got my last computer! After waiting a few years for Win7 to stabilize, I’m giving Win7 a shot now and the bad memories are coming back.

    As Hannah noted, for some reason even when “some” users make hosts writable and run notepad with Admin privilege, it still doesn’t allow updates! But the real question is, why does it work easily for some people’s PC and not for others? That seems beyond crazy.

    I’m on a plain vanilla, fresh load of Win7, so no excuses. I can’t even change the permissions or ownership to my user even though I verified that I have admin permissions. I’m going to try the Safe Mode Option and hope it works. You know, it really shouldn’t be this hard, it’s just plain sad…Where’s that extra copy of XP..hmmm.

  22. IF I DID IT….Well, since Safe Mode didn’t work. I decided to try hitting it from the User Accounts side of things. Accidentally found this obscure option in Control Panel\User Accounts and Family Safety\User Accounts called “Change User Account Control settings”.

    In here, you can dumb down your security to “Never Notify”. While this seems counter-intuitive, essentially, it not only does Not Notify you when you make “illegal” changes, it doesn’t prevent you from making those changes either! (It is my belief that different vendors might be setting this to other levels, which is why the above instructions worked for some people and not for others.

    Mine was defaulted to level 3 on a Toshiba laptop.) If not for windows fear-mongering about use of this setting, I would probably just leave at level 1 (so I could effectively pretend that there is no secret Administrator account controlling MY computer). But I will go ahead and set it back to their paranoid file access when complete, and recommend you do the same.

    Now I can finally <a href="” target=”_blank”> that advertising juggernaut! Ingat!

    This frustrating moment brought to you by your friends at MS. (apologies if you didn’t enjoy the commentary)

  23. doesnt work.. still have no rights to the file… -1

  24. This does not work. Even running Notepad as Admin. When I go to save the /etc/host file it still forces a .txt extension. I cannot save the hosts file without a file extension, it forces an ext.

    Thinking of becoming a Mac fan……

  25. Instead of battling with windows notes to remove the .txt ext, use notepadd++, an excellent addition to your Windows setup :)

  26. Hi,

    I have a windows 7 operating system and I found everything all the way to system32 but I did not find the etc file. May someone help me with this predicament? I am looking for the host file, by the way.

    Thank you!!!

  27. Thank you for the detailed instructions. Very helpful!

  28. Works great. Thank you for pointing out the location of the file and reveal hidden files and folders.

  29. This worked for me after 1)right-clicking on the file and allowing all users full control and 2)unchecking read-only.

    After those two steps I was able to do edit the host file.

    Thanks a lot!

  30. To avoid saving hosts as hosts.txt – simply type “hosts” with quotation marks. Same as it’s always been. :-)

  31. Hi, I wanted to block some sites and have edited with followed by site name as below

    but facebook is still accessible even after restarting and clearing the browser cache.

    Pls help me.

  32. This works well for blocking unwanted sites on children’s computers, but is it possible to hide that file and create a dummy file to put in its place?

  33. My experience same as ae123

    Notepad run as administrator did not Save, but if I first changed Hosts properties as shown below Save worked:

    Properties, Security (‘Authenticated Users’ set by virus), Edit, Full Control, Apply, then unclick Read-only

  34. If you have Avira, then check the Settings. There is a checkmark that blocks you editing the host file.

  35. A lot of Windows struggles with the concept of a file name without an extension. But there’s an easy cheat.

    If you tell Notepad to save the file (or Save As and let the name be “hosts”) it will save “hosts.txt”.

    If you tell Notepad to Save As and specify the name as “hosts.” (note the period) then it will save “hosts”.

    (No, you don’t need/want the quotes.)

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

  37. If you have Avira anti virus installed, you need to go into your settings general>security>system protection and uncheck protect windows hosts file from changes, otherwise when you try to save it just says access denied due to lack of permissions

  38. Thanks! I can never remember the path.

  39. Except that doesn’t work. It still saves it as a .txt file which is not a hosts file.

  40. Thank you, Kuzzcor !!!

    LOOK: “Now, open the host file from the File menu”
    i.e. Open notepad as instructed. In notepad click on File, now click Open… nav to hosts file. Voila!
    All better :)

    Kuzzcor says:
    January 21, 2013 at 8:38 am
    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!!!

  41. So often when fixing problems on my computer (practically always) I end up with incorrect, misguided and irrelevant web sites trying to sell me something. So I was rather surprised that I got such clear, succinct and straightforward support from HelpDeskGeek.

  42. Additionally, I did simply go to my windows folder and did a search for ‘hosts’ to come up with the proper file. Also, I did need to uncheck my Avira blocking any changes to the host file.

Leave a Reply

Your email address will not be published. Required fields are marked *