localhost lookup fails, browser tries www.localhost.com instead

Maen picture Maen · Mar 18, 2009 · Viewed 8.6k times · Source

I used to run web applications all the time on my laptop, no problems, I am using VWD 2008 Express, i have the latest framework, Windows Vista Home Basic...etc.. Now, when ever i try to run a website, or even chose to Show a Page in Browser from Within VWD, the browser (both IE and Firefox) keeps looking for www.localhost.com...

I tried to copy the address of and paste it directly in the title bar, nothing, same problem i tried to get that address from the balloon notification (the one that pops up when you run any ASP.net project), still nothing happens...

My colleague is facing the same problem, but for him, he can simply copy and paste the url in the address bar, but its not working with me....Heeeeeellllllllllllllllp

Answer

schnaader picture schnaader · Mar 18, 2009

Check your hosts file, it should be redirecting localhost to 127.0.0.1 and nothing else. The entry that will cause this error should look like this:

127.0.0.1    www.localhost.com 

If you find this, remove it or change www.localhost.com to localhost.

You can also try to post one of these in the adress bar:

127.0.0.1
http://localhost

Note that the hosts file is a popular victim of viruses, so if is has been modified, you might run a check on viruses.

Also see the discussion here.