Can't connect to localhost via browser. Can ping localhost

I’m trying to connect to localhost through my browser to learn some Apache Tomcat stuff.

When I tried to connect to localhost through Firefox, I couldn’t; when I tried through Internet Explorer, I could the first time, but not after that.

I’m using Windows 7, and changed the hosts file to point localhost to 127.0.0.1. I can successfully ping localhost and 127.0.0.1.

I have tried turning off my antivirus and my Windows Firewall, but to no avail.

What am I doing wrong?


Solution 1:

Your problem comes from your Tomcat and Apache configurations.

When you type in localhost into Internet Explorer, it automatically suposes you're connecting to port 80.

You’re going to have to make sure that Apache is correctly configured to work with Tomcat.

You can also try out your tomcat server by connecting to:

 http://localhost:portNumber 

That is, add the port number you’ve configured TomCat for after a colon… Try http://localhost:8080 for a start.

Solution 2:

Run tasklist from command prompt and note the process ID for Tomcat

Run netstat -noa and look for the the process ID you noted above. The 2nd column should show you something like 0.0.0.0:xxxxx. If there is an entry here for the process ID for Tomcat then Tomcat is definitely listening for connections properly. If not, Tomcat's broken and you may need to reinstall it or dive into the Tomcat logs (since it seems to be running but not listening properly).

There might be a few entries for the process ID, each giving a different port. Try them all because I believe you can forward one port to another in Tomcat.