Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to edit my hosts file in Windows 8 Pro. When I open C:\Windows\System32\Drivers\etc\hosts in notepad++ or any other text editor, make changes and attempt to save, I get a dialog that tells me "Save failed: Please check if this file is opened in another program."

I can't think of what would be using it (other than a browser, iis, and windows defender). I've never encountered this problem in Windows 7. I have used Process Explorer to try and identify any processes that are currently using the Hosts file but when I search Process Explorer for the "Handle or DLL substring" 'hosts' it doesn't return anything. I've looked around Process Explorer to see if there is any other way to search for processes consuming the file, but haven't had any luck.

I've also tried simply stopping the Windows Defender service and stopping the WWW Service.

Any suggestions would be greatly appreciated!

share|improve this question

migrated from Sep 18 '12 at 16:34

This question came from our site for system and network administrators.

Process Explorer itself has been known to sometimes keep a file open. Also make sure you run notepad As Administrator. I've had no issues editing hosts file in win8. – Bret Fisher Sep 18 '12 at 16:17
Running as Administrator was the answer, Thanks Bret. – David Sulpy Sep 18 '12 at 16:27
Don't overlook excluding hosts file from Windows Defender, amongst any other AV programs installed, before attempting to modify it following the advice here. See here for further instructions;… – user341610 Jul 6 '14 at 8:09
Related: hosts file ignored, how to troubleshoot? on Server Fault. – Arjan Jun 21 '15 at 13:46
-1 You write that you get this error in any text editor "Save failed: Please check if this file is opened in another program" <-- I do not believe you. I google that and from the results i've seen, only notepad++ comes up – barlop Jul 24 '15 at 8:43
up vote 33 down vote accepted

You have to run Notepad++ as administrator. Otherwise you won't have the neccessary permissions to edit that file.

share|improve this answer
Is there any way to make it so you don't have to run as admin to edit that file? – Sawtaytoes Sep 18 '12 at 17:48
Not that i'm aware of. – Frederik Nielsen Sep 18 '12 at 18:31
@Saturn2888 I would highly advise that you not change the permissions. Otherwise, A virus could hijack all of your webbrowsing by injecting DNS entries into it for the websites you go to, and redirect you to malicious websites. – Darth Android Sep 18 '12 at 18:51
If you're frustrated with the whole Run as Admin thing here's how you can use the Shell Extension shortcut to do this: 1) Right click hosts file -> Open in Notepad++ 2) Close Notepad++ 3) Run Notepad++ as administrator. The file should be still open as N++ remembers the last file(s) you had open. Saves you digging through the file-open dialog. – Aren B Sep 18 '12 at 19:48
@Aren B Sadly, Notepad++ run as admin completely forgets all tabs I had open as a user. It's really annoying. – Sawtaytoes Sep 22 '12 at 1:52

If you actually have administrator rights, then you're probably fighting against UAC. Make sure to launch your favorite text editor by right-clicking on it and selecting "Run as administrator".

share|improve this answer
Great point. I am running as a user with administrative rights. – David Sulpy Sep 18 '12 at 16:40

I had the same case, and couldn't change the hosts file even after I checked if I had all the permissions in the user settings or the hosts file's permissions.

ANSWER: Some antivirus software (in my case AVIRA)blocks everything in changing hosts files in their security options. Disable it for a minute, and change. Be careful, it can be risky!

share|improve this answer
AVIRA was the problem in my case thx for the hint! – IvanL Feb 7 '14 at 16:10

You may also want to check your permissions on the host file itself. You may run as administrator but you may not have the rights to edit the file.

share|improve this answer

Copy the hosts file to another location on the PC (like Documents) and edit in that location. copy hosts file back to original location. Worked for me.

share|improve this answer
this achieves the same result as @BenFisher 's comment... IF a permission dialog pops up during the file replace and IF the file is not in use. – Lorenzo Von Matterhorn Sep 19 '13 at 22:54

Running as admin didn't work in Windows 8 for me. Here's what I did to solve the problem:

  • Disconnect from net by unplugging network cable (or disable wireless)
  • Find hosts file. right click --> properties --> security
  • Click Users then edit
  • Add write for users (admin has write but didn't work)
  • Edit file by running notepad as admin
  • Save file
  • Remove write for users
  • Reconnect to net.
share|improve this answer
it would be nice if the person who marked this as un helpful left a little note saying why it was unhelpful. this worked for me when the above advice was not working. thanks to peter for the tip. – nero Jun 27 '13 at 9:46
Probably because it appeared to be more of a comment than an answer. I've edited your answer to be a little more readable, and recognizable as an answer. – KronoS Jun 27 '13 at 14:18

You must log in to answer this question.

protected by Community Jul 6 '14 at 9:51

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged .