Wednesday, December 20, 2006

Web Development - 127.0.0.1 works but localhost doesn't

Summary: I ran into an issue recently when I was setting up a new computer as a development system. I was using Netbeans as my IDE. In order to develop and test JSP applications, I needed to install Tomcat. Once I had everything installed and configured, I built and ran an application that I knew worked because it was running fine on a different computer. Same configuration, same source code but was unable to run it on the new computer. The issue was that I was receiving an HTTP 500 - Internal Server Error when attempting to access any web pages on the computer using http://localhost as the URL. The first thing I should have tried was attempt to access the application using http://127.0.0.1/ instead of http://localhost/. But instead, I proceeded to uninstall and re-install everything! Including all of the Java components. When this didn't work, I tried installing the Sun Java Application Server thinking there might be something wrong with Tomcat. This didn't work either. I checked the local hosts file and didn't see anything out of the norm. After fighting with this issue for a few days, I finally figured out what the problem was and how to fix it, but till this day could not tell you why the problem exists.

Resolution: After comparing all of the configuration options on the computer that worked with the one that didn't, I noticed that the only difference was that the new computer's browser was configured to use a proxy server. When I removed the proxy configuration from the browser settings, I was then able to access all locally hosted applications using the http://localhost/ URL as well as the http://127.0.0.1/ URL. Who knows why....

2 Comments:

Blogger Janea said...

It seems this issue may be related to the problem I described in the following post http://janeataylor.blogspot.com/2007/01/unable-to-open-admin-page-for-local.html

The loopback adapter provides a static IP address and "fakes" the location of the application/URL.

January 10, 2007 9:29 AM  
Blogger Chris said...

I wonder if the proxy was causing localhost to be resolved in a strange way. Anyway, I might have tried using nslookup or some equivalent to see how "localhost" and also 127.0.0.1 resolve.

June 30, 2007 9:39 PM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home