In Windows and linux, killing tomcat processes can also solve the problem of occupying other ports.
1. application scenarios
In Windows or linux, when we start a tomcat server, we often find that port 8080 is occupied, and we do not know how to stop the tomcat server.
2. Killing processes in the window environment
1. First, find the PID of the process that occupies port 8080 (Tomcat is port 8080 by default. If you have modified the tomcat listening port, enter your tomcat port number.)
netstat -ano | findstr 8080
The last column of the command output indicates the number of processes that occupy port 8080, which is assumed to be 9572.
2. kill this process
taskkill /f /pid 9572
In this way, port 8080 is released.
3. Shut down the tomcat process in linux
1. Check whether tomcat is running.
ps -ef |grep tomcat
If tomcat is running, the following results are displayed:
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, we can know that the process number executed by tomcat is 5144.
2. Killing Processes
Run the following command:
pid = 5144 kill -9 5144
You can completely kill tomcat.
4. Exceptions
When I start IDEA tomcat again, the following error is reported.
Connected to the target VM, address: '2017. 0.0.1: 50363 ', transport: 'socket' error: the proxy throws an 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: '2017. 0.0.1: 50363 ', transport: 'socket'
The main cause of the error is that port 1099 is occupied and we need to kill the process.
Run the following command:
netstat -ano | findstr 1099
I learned the process number: 9992.
Kill process 9992
taskkill /f /pid 9992
You can start it normally.
Thank you: Thank you for reading this article!