Friday, April 11, 2008

hostname works but localhost and local loop back address do not work in IE

I recently ran into a strange issue and spent about a day troubleshooting this so I thought I share my findings here.

I had a classic ASP webapp running on a virtual system and I could access it using http://localhost/webapp/ or URLs. No problem, until I made the following changes:

  1. Added the virtual system to our domain to be able to access some apps

  2. Moved the virtual system files to an external HDD

I could no longer access the app using either one of above URLs. When I tried to access the app or even an image file off of this web app using http://localhost/webapp/, I get a "DNS Fail" error message as shown below:

And if I tried to access the app using, I get a "Access Denied" error message as shown below:

I am not sure which one of these is caused this issue or if the above changes are even the culprits.

I tried the usual stuff (not necessarily in the order listed below) like the following:

  1. Checked my C:\WINDOWS\SYSTEM32\drivers\etc\hosts file and made sure local loop back address is mapped to localhost.

  2. Pinged the localhost to make sure it is getting resolved correctly.

  3. Checked the IIS configuration to make sure the "IP Address" is set to "All Unassigned" in the "Web Site" tab:

  4. I have checked the permissions on the folder mapped to the Home Directory.

  5. I have un-installed and re-installed IIS.

  6. Followed the steps given in the Microsoft KB Article ID: 271071 (How to set required NTFS permissions and user rights for an IIS 5.0 Web server). CAUTION: This process took a long time to complete.

After trying few other things that I could not quite recall all the details, I wondered if I should access the webapp using the hostname, i.e. http://myhost/webapp and bingo! it worked. I am still not sure why hostname works and the other two don't. I searched using Google and I did not find any similar issues, so I do not know what is causing it.

I gave up for the day and decided to leave it like that. The next day, I wanted to give it another try since it was really bothering me.

I decided to use the telnet command to fetch the starting page using all three URLs and lo and behold all of them retrieved the right content. So, there is nothing in the IIS that is causing this, so some setting in Internet Explorer (IE) must be causing it. I tweaked a few settings in IE and they did not fix the problem. Then I found the reset all button.

I reset all the IE settings and restarted IE and now I could access my app using all three URLs.

So, I still do not know what caused this strange issue, but am happy that it is fixed now. I guess, if it happens again I know what to try and where to look.

Hope you find this useful.



Bhavin said...


I have the exact same problem. I just do not know what happenned before ... but I cannot access my websites using local host of! Instead, if i use the IP address or the host name, it works!!
Did you manage to get a resolution?

Sonny Nallamilli said...


If you have tried resetting the IE and it still does not work, make sure loop back address is correctly mapped in your host file.

Also under IE options, go to the Connections tab, click on the LAN settings and unselect the checkbox "Automatically detect settings" if it is selected and OK the change and try again. If there is a Proxy webserver that might not resolve the local addresses. I am using IE 7 and if you are using a different version of IE you might need to use different path to get to this setting. Hope that helps.

Good luck.