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

Our ISP accidentally switched us from a static IP to DHCP (long story) and it might be another day or two before we get our static IP back. In the meantime I'm trying to just use a host file on my machine but I can't get it to take. I've done this a million times before but I can't seem to get it to work on my Windows 7 machine. Here's my simple one line that I'm trying to do:

I've added that to c:\windows\system32\drivers\etc\hosts using an elevated notepad. Then I run ipconfig /flushdns and arp -d and try pinging it with ping but I just get:

Ping request could not find host Please check the name and try again.

If I repeat the exact same process on a virtual XP machine on the same physical machine it resolves to which is exactly what I want.

There's a similar post here that talks about checking the proxy settings but I don't have one configured.

I've also checked the value of the registry key below and its set at 500 which is second lowest (class is 8):


I also read a post that Windows 7 wants 8 spaces between the IP and the host and I tried that (as well as 7 spaces, 1 space, 1 tab) to no avail.

I don't have time to setup a DNS server locally so that's not an option. This is all command-line, I'm not even at the browser level yet. Yes, I'm sure that c:\Windows is the correct path, I've checked %SystemRoot%. And yes, I'm sure that I'm saving the file as hosts without an extension.

share|improve this question
You could use if your router supports it. After you setup an account and have the settings configured in your router, have your domain forward to – ngen Feb 10 '11 at 20:58
There are lots of subdomains on the domain that I need to route that are working just fine and need to stay as it. For example, mail, www, etc as well as TXT records like SPF. I'd really like to avoid duplicating all of these records so that I can fix just 1 for a day or two. – Chris Haas Feb 10 '11 at 21:04
Can this system ping itself Is there a firewall in the way? What are you trying to redirect? What's the setup of the network when it is normally working? As in where is the domain you are actually looking for because you said it was a static IP? Are you trying to point internally via hosts to a local resource? – Dan M. Feb 10 '11 at 21:06
Yes, I can ping and localhost, the latter resolves to ::1: although we're only using IP4. The domain I'm trying to redirect is a standard .com domain. Our network is a standard Windows AD setup. We have a local Windows DNS that we use for AD only (see my previous comment about not wanting to recreate dozens of records). Most subdomains of the domain that I'm routing are external, a few point to our old static IP which is the IP of our DSL line which I'm trying to change via host files. I'm updating the main DNS, too, but I can't adjust TTL so it takes a while to update. – Chris Haas Feb 10 '11 at 21:21
And to take the network out of it I unplugged, ran ipconfig /flushdns, arp -d and for the heck of it nbtstat -R and still can't get it to resolve. Yes, pinging localhost and still worked just fine without my network connection. No, I don't have a wi-fi connection, too. – Chris Haas Feb 10 '11 at 21:26
up vote 1 down vote accepted

The Windows 7 hosts file can 'play up' if there are multiple spaces between the IP address and the host name - try using:

...and rename the current one to hosts.bak and make up the hosts file again using notepad to make sure there's no unicode in there.

share|improve this answer
I'm going to mark this as answered because this came closest. The spaces wasn't an issue, I had tried it with many combinations. I also checked with XV32 and there's no high-order bits or Unicode in there. But what did work was deleting the original hosts file and writing a new one. Subsequent changes now work immediately, too. – Chris Haas Feb 11 '11 at 14:30

Are you sure that your IP stack has the hosts file enabled? I recall that by policy it could be disabled, which is a security feature. Scratch installs of Win7 have it enabled, I believe, but it's possible if you're using a corporate machine that it's been disabled and you'll need to re-enable it - I think this is done through the Network control panel as an admin.

You sound like you're very computer literate, so don't take offense, but here is another common error:

  • Editing hosts in notepad can sometimes result in notepad saving "hosts.txt" instead -- so make sure you're editing and saving the correct file.

I've also read that possibly restarting in safe mode and editing the file might work. This seems like hokum to me, but since I saw it in several threads, I'd pass it along.

Finally try changing localhost in the hosts file and see if that makes any difference to be able to ping localhost? If not, then it would seem you're not messing with the right file? Or the file you're messing with is being ignored b/c your IP stack is not looking for any hosts file.. Hope this helps.

share|improve this answer

You must log in to answer this question.

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