6

Windows系统中,如何快速找到端口被占用的进程?

 2 years ago
source link: https://blog.51cto.com/u_6740480/5372105
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

在本地调试代码时,经常遇到端口被占用导致启动失败的问题,又不能很快找到哪个进程占用了端口,很是恼火。

今天,我们用shell命令轻松搞定。

一、打开命令提示符

window+R 组合键,调出命令窗口。输入CMD回车,打开命令提示符。

Windows系统中,如何快速找到端口被占用的进程?_命令提示符

二、查看被占用端口对应的 PID

输入命令:

netstat -aon|findstr "11800"

回车执行该命令,输出:

  TCP    10.201.242.96:11800    120.241.17.13:443      CLOSE_WAIT      21252

最后一位数字就是 PID, 这里是 21252。

三、查看指定 PID 的进程

输入命令:

tasklist|findstr "21252"

回车执行该命令,输出:

QQMusic.exe                  21252 Console                   13    183,552 K

原来是QQ音乐占用了端口😓

四、结束指定 PID 的进程

输入命令:

taskkill /T /F /PID 21252

回车执行该命令,输出:

成功: 已终止 PID 13296 (属于 PID 21252 子进程)的进程。
成功: 已终止 PID 21252 (属于 PID 19536 子进程)的进程。

结束这个进程以后,端口就被释放了。

感谢你这么帅,还给我点赞


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK