Janea Taylor – COMPUTERS ARE FUN!


127.0.0.1 works but localhost doesn’t
December 20, 2006, 3:40 pm
Filed under: Development, JSP, Technical Issues

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….