sexta-feira, julho 18, 2008

localhost redirecting to www.localhost.com

For some time now, each time I typed localhost on Firefox it tried to open www.localhost.com, but accessing 127.0.0.1 worked just fine.

I was lazy about fixing it, but today I got pissed off and decided to find out what the hell was happening.

After googling a little bit I found this forum post: http://www.wilderssecurity.com/archive/index.php/t-198020.html

It happens because of Firefox and Vista's IPv6 support. I'm not sure why it happens, but there are 3 easy solutions:

  1. Remove the IPv6 entry for localhost in the windows hosts file (explained bellow).
  2. Disable Firefox's IPv6 support.
  3. Disable Vista's IPv6 support.

As I don't use IPv6 at all, my choice, is the quickest and dirtiest one: remove the entry from the hosts file.

To do it, just do the following:

  1. Open notepad as Administrator and edit the file: C:\Windows\System32\drivers\etc\hosts
  2. Remove the line: ::1 localhost
  3. Save the file.
  4. Open up the command prompt as Administrator (hit the windows key, type cmd and then hit Ctrl + Shift + Enter)
  5. Execute the command: ipconfig /flushdns
  6. That's all folks :)

I don't know why Firefox tries to open www.localhost.com, but if you are asking yourself what is "::1 localhost", it is the IPv6 equivalent of 127.0.0.1, you can read more about it at the Localhost's entry at wikipedia.