Windos
1、找到占用端口的进程号
netstat -ano | findstr “8080”
执行结果:
C:\Users\lenovo>netstat -ano | findstr "8080" TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 15676 TCP [::]:8080 [::]:0 LISTENING 15676 TCP [::1]:8080 [::1]:56021 CLOSE_WAIT 15676 TCP [::1]:8080 [::1]:56477 CLOSE_WAIT 15676 TCP [::1]:56021 [::1]:8080 FIN_WAIT_2 10444 TCP [::1]:56477 [::1]:8080 FIN_WAIT_2 10444
2、查看该进程名称
tasklist | findstr "10444"
执行结果:
C:\Users\lenovo>netstat -ano | findstr "8080" TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 15676 TCP [::]:8080 [::]:0 LISTENING 15676 TCP [::1]:8080 [::1]:56021 CLOSE_WAIT 15676 TCP [::1]:8080 [::1]:56477 CLOSE_WAIT 15676 TCP [::1]:56021 [::1]:8080 FIN_WAIT_2 10444 TCP [::1]:56477 [::1]:8080 FIN_WAIT_2 10444 C:\Users\lenovo>tasklist | findstr "10444" chrome.exe 10444 Console 59 44,724 K
3、杀掉该占用端口号的进程
taskkill /f /t /im idea64.exe ## 根据名字删除 taskkill /f /pid 20388 ## 根据进程号删除
Linux
1、找到端口的占用情况
netstat -anp|grep 8080
执行结果
-bash-4.1# clear -bash-4.1# netstat -anp|grep 8080 tcp 0 0 :::8080 :::* LISTEN
2、杀死进程即可
kill -9 12837