How to view the port status and kill the process in windows
View port status
Netstat-a-n
NETSTAT [-a] [-B] [-e] [-n] [-o] [-p proto] [-r] [-s] [-v] [interval ]-
Display All connection and listening ports. -B shows the executable components that contain each connection or listening port.
In some cases, it is known that the executable component has multiple independent components, and in these cases, the component sequence that includes creating a connection or listening port is displayed.
In this case, the executable component name is in the [] at the bottom, and the component called by the component is at the top until the TCP/IP part. Note that this option may take a long time and may fail if you do not have sufficient permissions.
-E displays Ethernet statistics. This option can be combined with the-s option. -N: the address and port number are displayed in numbers.
-O displays the ID of the process associated with each connection. -P proto indicates the connection of the Protocol specified by proto. proto can be one of the following protocols: TCP, UDP, TCPv6, or UDPv6.
If used with the-s option to display statistics by Protocol, proto can be one of the following protocols: IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6. -R shows the route table.
-S displays statistics by protocol. By default, statistics of IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6 are displayed. The-p option is used to specify a subset of default conditions.
When used together with option-B, components that contain connection or listening ports are displayed for All executable components. Interval re-displays the selected statistics. The pause interval between each display (in seconds ).
Press CTRL + C to stop displaying statistics again. If omitted, netstat displays the current configuration information (only once)
Established listening time-WAIT
View the status of a specified port:
Step 1: Find the corresponding process number based on the port number
Netstat-ano | findstr 80 // list ports that are extremely occupied by processes and contain 80
Port 8081 is occupied by processes with a PID (process number) of 2000.
Step 2: Search for the process name based on the process number
Tasklist | findstr2000
Find the program in the task manager and manually kill it. So far, it has been completed.
If the program cannot be found in task manager. The program has to be killed from the command line. The command is as follows:
Taskkill-PID <process number>-F // force stop a Process <