Close the port number command occupied by windows

Sometimes when we start some services on windows, such as tomcat, redis, mysql, etc. After shutting down the service, it is found that the port is still occupied. At this time, the port can be closed by the following methods

1. Query the port number process

 netstat -ano | findstr "端口号"

illustrate:

  • netstat -ano: list all processes
  • | findstr "port number": Find the string specifying the port number through the pipe from the previous result

2. End the process according to the pid number

taskkill /pid 进程号 /f

illustrate:

  • taskkill: kill process
  • /pid: kill process by process id
  • /f: force the command to execute

Guess you like

Origin blog.csdn.net/qq_41570752/article/details/123001239