cmd kills the process of the port according to the pid

Applicable scenario 1: When starting tomcat, a socket error is displayed, because eclipse did not stop the project normally after starting the project, resulting in the project still running in the background, the port is still occupied, and an error will be reported when it runs again. Here, according to the cmd, find the pid of the window to kill the background process. Of course, this method is not recommended. Go to the task manager to find the java program, and then kill it is the fastest way.
Applicable scenario 2: A startup port is occupied, and the task manager cannot find the occupying program.

1. Find the pid according to the port in cmd

netstat -ano|findstr “8080”

insert image description here

2. Kill the background process according to the pid in cmd

taskkill /f /20260(PID)
insert image description here

Guess you like

Origin blog.csdn.net/qq_40690077/article/details/125798578