Check the port occupancy and release the port under Win

During development, it is often encountered that the port is accidentally occupied and the port needs to be released. The general solution is to find the process number associated with the occupied port, that is, the PID, and then terminate the process through the PID to release the port.


netstat command

Display protocol statistics and current TCP/IP network connection, common parameters:

-a: show all connections and listening ports

-n: Express IP and Port information in digital form

-o: Display the process ID number associated with each connection, ie PID

findstr

Find the line that contains the specified character string, and print out the line information. It is usually used in conjunction with the pipe|, and uses the command to search and filter the output results of the command before the pipe|, and display the result line that contains the specified character.

Check the usage of port 135:

netstat -ano | findstr "135"

 

taskkill command

Terminate the process, the parameters are as follows:

/PID processid Specifies the PID of the process to be terminated

/F Forcefully terminate the process

Release the specified port

As above, the PID of the process associated with the occupied port can be obtained through the netstat and findstr commands. In this article, the PID number of the process associated with port 135 is 352.

Execute the following command to terminate the process (processid = 352), thereby releasing port 135

taskkill /pid 352 /f

Guess you like

Origin blog.csdn.net/wangshiqi666/article/details/130556816