Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
How do you edit hosts file on Windows 7

Every time I try to edit it in Notepad it says "Access is Denied".

share|improve this question
add comment

marked as duplicate by slhck, Oliver Salzburg, Synetech, nhinkle Mar 19 '12 at 19:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

5 Answers

up vote 5 down vote accepted

The Hosts file is permission protected for security reasons, and has been since some iteration of Windows (I think it was Vista that started it).

In order to edit the Hosts file, you will need to escalate the privileges of your editor. To do that with notepad, type Notepad into your start-bar, then right click it and Run as Administrator. You may get a dialogue asking you for a password. When that is done, Notepad will open with administrator privileges, allowing you to edit the Hosts file.

This example uses Notepad, but the method can be used on your favourite text editor.

share|improve this answer
add comment

You need to be running Notepad as an administrator. An easy way to do so: Start -> Search "notepad" -> Right click on the Notepad result and select "Run as Administrator." With Notepad open, select File -> Open... and browse to your hosts file.

share|improve this answer
    
Alternately, if the 'new' Start Menu is enabled: Click Start, type Notepad, then press CTRL-SHIFT-ENTER, keep holding CTRL-SHIFT until you receive a UAC prompt (or Notepad opens). You should be able to open Hosts –  EKW Mar 19 '12 at 18:42
    
By "search" I meant the "quick-jump" field on the Start menu. I'm not sure what it's officially called, but we're both talking about the same thing. :) –  Garrett Mar 19 '12 at 20:21
    
We are, but with CTRL-SHIFT-ENTER, your hands don't have to leave the keyboard. ;) –  EKW Mar 19 '12 at 23:37
    
Well if we're nit-picking, he should be using the super key instead of clicking Start :P –  Garrett Mar 19 '12 at 23:57
add comment

My most recent idea was to create a shortcut to edit it:

right click on your desktop, choose "New", then "Shortcut"

if you installed Windows 7 in a default location e.g. "C:\Windows", simply paste:

C:\Windows\System32\notepad.exe "C:\windows\system32\drivers\etc\hosts"

as the location of your item. Click "Next"

Type a descriptive name and click "Finish"

Now, right click on the newly created shortcut and choose "Properties".

Click on "Advanced" on the window that pops up, and choose "Run as Administrator"

confirm, confirm.

Now when you double click the shortcut, windows will ask to confirmation to edit your HOSTS file as administrator, and you can simply hit CTRL+S to update it

If you use firefox, this is a great extension to add:

https://addons.mozilla.org/en-US/firefox/addon/dns-flusher

share|improve this answer
add comment

Have you tried save as > .txt > then edit as you wish > change the extension of file from .txt to "nothing" then copy over you existing hosts file.you must close your browser before you copy/paste your edited version.

share|improve this answer
add comment

I copy and paste the HOSTS file onto my desktop. I edit and save it on my Desktop and then drag it back over to c:\windows\system32\drivers\etc. It will ask for elevation of privileges and then works.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.