How to Check Who Occupies a Port on the Windows Operating System

On Linux, it is easy to see which process the port is occupied by, just use netstat -tunlp

For example: check port 22 occupancy

[root@node01 ~]# netstat -tunlp|grep 22

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 13682/sshd

tcp6 0 0 :::22 :::* LISTEN 13682/sshd

On windows, there are 2 methods

Use cmd to find the occupied port

Command: netstat -ano

-a Displays all connections and listening ports.

-n Displays addresses and port numbers numerically.

-o Displays the process ID associated with the connection.

Example: View the port of MySQL

C:\Users\hoplite> netstat -ano | findstr 3306

Find out how to end the process?

After getting the above process number, you can use taskkill /T /F /PID <process number> to end the process

Find Occupied Ports Using PowerShell

get-nettcpconnection -localport port number|ft l*port,o*ss

Find out how to end the process?

Use taskkill /T /F /PID <process number> to end the process

extend

Get-NetTCPConnection -remoteaddress 192.168.100.107 #Find the connection to the specified remote IP

Get-NetTCPConnection -remoteport 22 #Find the connection to the specified remote PORT

Get-NetTCPConnection -localport 64176 #Find the connection that occupies the local port

Guess you like

Origin blog.csdn.net/weixin_44496870/article/details/131698187