I came across an annoying thing on Vista today when trying to run a Website using http://localhost:#####/WebSite, ##### being the dynamically allocated port for running the website locally via Visual Studio 2005. I discovered that it was the hosts file that was causing the issue. I was getting an error such as "Internet Explorer cannot display the webpage".

To fix this problem you'll need to do the following things.

Access your HOSTS file using the following instructions.
http://www.dafran.net/Blog/post/Changing-your-hosts-file-in-Vista.aspx

By default the Vista HOSTS file contains a single Line.
::1             localhost

This is a IPv6 entry and you more than likely need a conventional IPv4 entry, as show here.
127.0.0.1    localhost

There are a few ways to resolve this problem.
1. Remove the ::1  localhost line
2. Place a # (hash or pound) symbol in front of the ::1 Localhost line so it reads #::1  localhost. This will effectively comment it out so that the default 127.0.0.1 will be used.
3. You can also "add" a new line  that reads 127.0.0.1  localhost

Combinations that work
-----------------------------------
<nothing at all>
-----------------------------------
::1  localhost
127.0.0.1  localhost
-----------------------------------
#::1  localhost
-----------------------------------
#::1  localhost
127.0.0.1  localhost
-----------------------------------
127.0.0.1  localhost

 For more information on HOST files see http://en.wikipedia.org/wiki/Localhost


By default, if you try to modify your hosts file in Vista, it will not let you save it.  It tells you that you don't have permission.  To successfully modify the hosts file, run notepad.exe as an administrator and open the file.

1)  Browse to Start -> All Programs -> Accessories
2)  Right click "Notepad" and select "Run as administrator"
3)  Click "Continue" on the UAC prompt
4)  Click File -> Open
5)  Browse to "C:\Windows\System32\Drivers\etc"
6)  Change the file filter drop down box from "Text Documents (*.txt)" to "All Files (*.*)"
7)  Select "hosts" and click "Open"
8)  Make the needed changes and close Notepad.  Save when prompted.


Dave Stuart

The Life and Times of a .NET developer and all the challenges that come with it...