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:
%systemroot%\system32\drivers\etc\
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.
Click on the View tab and then click on the Show hidden files, folders, and drives radio button under Hidden files and folders.
Now navigate to the directory above and open the hosts file and make your changes.
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.
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.
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.
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!




Or use HostsMan. Less work.
http://www.abelhadigital.com
It is not necessary to check "show hidden files and folders" because "hosts" is not a hidden file.
It worked! Thanks!
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
Nice addition to two other articles, ref:
mvps.org/winhelp2002/hosts.htm
mvps.org/winhelp2002/hostswin7.htm
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?
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!
Keep reading Ginger, it doesn't work unless you open Notepad the way it shows after the point you stopped.
Tells me "access denied." Am I missing something?
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.
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.
Thanks for the useful post. Solved my Problem. :)
Awesome. Thanks a million!!
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.
don't delete anything
just add a line for the ipaddress that you want
# localhost name resolution is handled within DNS itself.
#127.0.0.1 localhost
#::1 localhost
test.yoursite.com 143.225.125.66
Thanks, man! It really worked. ;-)
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?
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).
its work..
thx :)
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.
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.