1. Application Scenario
In Windows or Linux operating systems, when we start a Tomcat server, we often find that port 8080 is already in use, and we don't know how to stop the Tomcat server.
2. Kill the process in window environment
1, first find to occupy 8080 port process number PID is how much (tomcat by default is 8080 port, if you modify the Tomcat listening port, please enter your tomcat port number )
Netstat-ano | findstr 8080
The last column of this command output indicates the number of process numbers that occupy port 8080, assuming 9572
2. Kill the Process
taskkill/f/pid 9572
So the 8080 port is released.
3. Shut down Tomcat process under Linux OS
1. See if Tomcat is running
If there is a tomcat there will be a result similar to the following:
Sun 5144 1 0 10:21 pts/1 00:00:06/java/jdk/bin/java-djava.util.logging.manager= Org.apache.juli.classloaderlogmanager-djava.endorsed.dirs=/java/tomcat/common/endorsed-classpath:/java/tomcat/ bin/bootstrap.jar:/java/tomcat/bin/commons-logging-api.jar-dcatalina.base=/java/tomcat-dcatalina.home=/java/ Tomcat-djava.io.tmpdir=/java/tomcat/temp org.apache.catalina.startup.Bootstrap Start
From the above output information, we can know that Tomcat executes a process number of 5144
2. Kill the Process
Execute the following command
You can kill Tomcat completely.
4, the abnormal situation encountered
When I started the idea Tomcat again, I reported the following error.
Connected to the target VM, address: ' 127.0.0.1:50363 ', Transport: ' Socket ' ERROR: Agent throws exception error: Java.rmi.server.ExportException : Port already in use:1099; Nested exception is: java.net.BindException:Address already in use:jvm_binddisconnected from the target VM, Address: ' 127.0.0.1:50363 ', Transport: ' Socket '
The main reason for the error is that the 1099 port is occupied and we need to kill the process.
Execute the following command:
Netstat-ano | findstr 1099
Know its process number: I found out it was 9992.
Kill process Number No. 9992.
taskkill/f/pid 9992
can start normally.
Thanks: Thank you for reading!
Kill Tomcat process in Windows and Linux environments-also resolves other port-occupied issues