1、启动 windows 的命令窗口,按键盘上的 win + R, 然后在输入框中输入 cmd,即可启动命令窗口
2、输入 netstat -ano
命令查看当前系统的所有端口的使用情况
netstat -ano
C:\Users\Administrator> netstat -ano
活动连接
协议 本地地址 外部地址 状态 PID
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 680
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:808 0.0.0.0:0 LISTENING 3352
TCP 0.0.0.0:5040 0.0.0.0:0 LISTENING 5080
TCP 0.0.0.0:5357 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:7680 0.0.0.0:0 LISTENING 1144
TCP 0.0.0.0:8888 0.0.0.0:0 LISTENING 1724
TCP 0.0.0.0:49664 0.0.0.0:0 LISTENING 772
TCP 0.0.0.0:49665 0.0.0.0:0 LISTENING 692
TCP 0.0.0.0:49666 0.0.0.0:0 LISTENING 1608
TCP 0.0.0.0:49667 0.0.0.0:0 LISTENING 1376
TCP 0.0.0.0:49668 0.0.0.0:0 LISTENING 3068
TCP 0.0.0.0:49669 0.0.0.0:0 LISTENING 764
TCP 0.0.0.0:49688 0.0.0.0:0 LISTENING 7492
TCP 0.0.0.0:49947 0.0.0.0:0 LISTENING 1724
TCP 0.0.0.0:51453 0.0.0.0:0 LISTENING 1728
TCP 0.0.0.0:51454 0.0.0.0:0 LISTENING 1720
3、通过 netstat -ano | findstr "端口"
命令查找特定端口被占用的应用程序
netstat -ano | findstr "端口"
C:\Users\Administrator> netstat -ano | findstr "8888"
TCP 0.0.0.0:8888 0.0.0.0:0 LISTENING 1724
TCP [::]:8888 [::]:0 LISTENING 1724
4、查看到对应进程 PID 之后,就可以通过 PID 查找对应的应用程序名称,使用命令: tasklist | findstr "进程ID"
tasklist | findstr "进程ID"
C:\Users\Administrator> tasklist | findstr "1724"
java.exe 1724 Console 1 250,308 K
5、根据进程ID或者进程名称杀掉相应的进程,命令为: taskkill /f /t /im "进程ID或进程名称"
taskkill /f /t /im "进程ID或进程名称"
C:\Users\Administrator> taskkill /f /t /im "1724"
成功: 已终止 PID 1724 (属于 PID 916 子进程)的进程。
成功杀掉进程之后再去查看端口占用情况就会发现没有应用占用了。