This article is participating in “Java Theme Month – Java Debug Notes Event”, see < Event link > for more details.

Q: What if several ports (8005, 8080, 8009) required by Tomcat server on localhost are already in use?

The following error occurred when I tried to run a simple JSP program on Tomcat in Eclipse.


Several ports (8005, 8080, 8009) required by Tomcat v6.0 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).
Copy the code

What is causing this and how can I fix it?

Answer 1:

You already have another Instance of Tomcat running. You can confirm this by visiting http://localhost:8080 in your Web browser and checking to see if you get the Tomcat default home page or a Tomcat-specific 404 error page. Both are valid evidence that Tomcat is working properly. If not, you get a browser-specific HTTP connection timeout error message.

You need to close it. Go to the/bin subfolder of the Tomcat installation folder and run the shutdown.bat (Windows) or shutdown.sh (Unix) script. If this does not work, close Eclipse, then open task Manager and kill all Java and/or Javaw processes.

Or, if you actually install it as a Windows service for some reason (this is for production purposes and doesn’t help while you’re developing), open the Service Manager (Start > Run > services.msc) and stop the Tomcat service. If necessary, uninstall the Windows service completely. For development purposes, a ZIP file alone is sufficient.

Alternatively, if your actual intention is to run two Tomcat instances at the same time, you must configure the second instance to listen on a different port. Consult the Tomcat documentation for more details.