How to fix Tomcat has failed to start: the port X is already in used?

13.5k views Asked by At

I'm trying to use a new installation of TomEE as a local server in Netbeans but i'm facing a weird issue. Everytime I try a port, it is in used. I tried many many ports but it is always in used. So I ran this command in command prompt:

netstat -aon

It listed all the listening ports with the PID. So I opened task manager and I found out that Java (TM) Platform SE Binary. I ended the process. Restarted Netbeans and everytime I end the java process, it seems it creates a new one not allowing me to use any port... Say I change it for another port, Java (TM) creates a new instance and uses the port I want to use throwing me a used port error in the IDE.

How am I supposed to fix this if each single time I change port, Java creates a process and use the exact same port?

3

There are 3 answers

0
Sarfaraz Khan On

As per your description it looks like net beans is using your tomcat so when you restart after changing the port your netbeans starts the tomcat server internally then when you're trying to start another tomcat instance you'e getting the error.Your can check you netbeans setting to disable tomcat. Better to get a binary distribution of tomcat and run it with different port and try if its working.

1
Sagar Pudi On

Change the port number by editing the server.xml file in TomEE installation directory.

for example:

<Connector port="18080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />
1
RajSharma On

Yo have to chnage the port number. Follow these steps.

1) Go to conf folder in tomcat installation directory e.g. C:\Tomcat 6.0\conf\

2) Edit following tag in server.xml file

3) Change the port=8080 value to your desired value for ex- 8085

4) Save file.