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 looking to edit the Windows TCP/IP hosts file (at c:\windows\system32\drivers\etc\hosts). I'm wondering, what is the best way to do this (on Windows XP)?

Let's say that I want to redirect, say, the site to I can find the IP address of, but what is the correct way to edit the HOSTS file? I'm thinking of using this syntax:

However, two things:

  • Is this the correct syntax? If so, is there a way to do it without having to find the IP address of Would just putting into where the IP address currently is work?
  • What is the best way to edit this file? I can't save to it because it is in use. Normally under these circumstances, I would go into Safe Mode and edit it from there, but is there an easier way (I'm thinking of killing some system processes...)?
share|improve this question
I've never had a problem editing the HOSTS file from Notepad (Start > Run > notepad c:\windows\system32\drivers\etc\hosts). Are you running some AV program that's keeping it locked? – quack quixote Oct 4 '09 at 1:27
oopsey, i was confusing myself because im on a vista comp right now. thanks @quack – Maxim Zaslavsky Oct 4 '09 at 1:33
yeah, it only appears locked because you didn't try to edit it with admin privs. start notepad.exe as admin, then you can edit it fine – davr Oct 4 '09 at 4:56
One small addition as a comment, as it is not answering your question: In your sample, the user would call from their browser, and would get redirected to a different IP address as specified in your hosts file. However, the browser will still send the Host header value as - so the webserver behind the different IP address will need to be able to handle that. Just redirecting to e.g. Bing's IP might not work, as their webserver might not accept Host: – BennyInc Sep 15 '11 at 12:37
up vote 9 down vote accepted

One easy way to edit the hosts file is using the freeware Windows program HostsMan.

HostsMan is a freeware application that lets you manage your Hosts file with ease

enter image description here

In Vista / Windows 7 it needs to run with administrative privileges, but it doesn't require going into safe mode.

share|improve this answer
+1 ... VERY nice find, thanks. – Molly7244 Oct 4 '09 at 1:16
Thank you! That worked! – Maxim Zaslavsky Oct 4 '09 at 1:34
+1 Nice program will keep away a lot of difficulties – aibk01 Sep 15 '11 at 14:29

You can find the IP addresses of the sites using ping in command prompt or use a lookup tool. Also make sure you tackle all of the combinations:

The file is read only, you can edit it by right-clicking and going into properties, then turning off read-only temporarily until you're done editing.

share|improve this answer
nslookup is probably more straightforward than ping for this task and it allows you to use another DNS server if you need it. – Joey Oct 4 '09 at 9:01
I doubt the 3rd line would work. (And you can also add the combinations on a single line.) – Arjan Oct 4 '09 at 9:46
You only need the IP need to type an extra 4 characters. Ping works fine. – John T Oct 4 '09 at 15:18

You should be able to edit the hosts file with Notepad, but it is a protected file by default in Windows Vista. You probably couldn't save the file because of permissions issues, not because it was in use.

To edit the file with Notepad, open it under the Administrator account, by right-clicking Notepad in your Start menu and choosing the Run as Administrator command.

share|improve this answer

when I need to edit my hosts file I am copying my hosts file to my desktop then edit it as I want.After editing it I move it to original hosts file's folder and replace the old file.I normally have admin rights while doing this.

share|improve this answer

Disable AV and edit with notepad. The one thing I find annoying is you are unable to choose ports for those IP address's added in the host. Incase I want to change my web traffic from 80 to 8080 or 4444 for some unknown reason.

share|improve this answer

You must log in to answer this question.

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