Sometimes when Tomcat is started, it fails to start, saying that the port is already occupied, so which program takes up the port?
How can I tell which process (program) is taking up the specified port?
Below I will be divided into two platforms (Windows,linux) for detailed description
- Windows system
Use the following command to find the PID (process ID) that occupies the specified port
<指定的端口号>
For example, find a process that occupies port 8080
Indicates that a process with a PID of 1532 consumes 8080 ports
Then we open the Task Manager, find the process,
So how do we kill the process?
taskkill 1532 /f
Note: PID is followed by
- Linux
Use the following command to find the PID (process ID) that occupies the specified port
-aonp|":80[ ]\+"|-F" " {‘print $0‘}
This is the process of querying 80 ports
Indicates that a process with a PID of 11116 consumes 80 ports
The following optimizations are followed:
netstat -aonp |grep "^[a-z]\+[]\+0[]\+0[]\+[0-9\.]\+:80[]\+"|awk -F" " {$0‘}
Well, let's check it out.
Sure enough, Tomcat takes up 80 ports.
What if only PID is displayed?
-anp|"^[a-z]\+[ ]\+0[ ]\+0[ ]\+[0-9\.]\+:80[ ]\+"|-F" " {‘print $7‘}|-d"/"-f1
So how do you kill the process in Linux?
kill -911116
My technical blog on the Iteye:
http://hw1287789687.iteye.com/
Kill the process that occupies the specified port