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:

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

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!

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.

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?

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…

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).

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.

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.

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.

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.

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

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.

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.

Most Commented

Aseem Kishore

Founder of Help Desk Geek and managing editor. He began blogging in 2007 and quit his job in 2010 to blog full-time.

SIGN UP FOR DAILY EMAIL NEWSLETTER

CONNECT WITH US

About Help Desk Geek

Welcome to Help Desk Geek- a blog full of help desk tips for IT Professionals. My name is Aseem Kishore and I work as a Systems Analyst in Dallas, TX. I graduated from Emory University in Atlanta, GA in 2002 with a degree in Computer Science and Mathematics.