关闭占用端口的程序 , 关闭tomcat , 关闭springboot , 杀进程

374 阅读1分钟

@TOC

Windows

1.用netstat -ano | findstr 端口号
找到占用端口的程序的pid

netstat -ano | findstr 8080

2.然后用 taskkill /pid pid /f 杀进程

taskkill /pid pid /f



Linux

方法1:用fuser

sudo fuser -k -n tcp 8080

方法2:用netstat -anp 加 kill -9

1.用netstat -anp | grep 端口号
找到占用端口的进程的pid

netstat -anp | grep 8080

2.kill -9 pid 杀进程

kill -9 pid

对比W和L的 netstat

WindowsLinux
netstat -ano | findstrnetstat -anp | grep
anoanp
taskkill /pid pid /fkill -9 pid