Mac解决端口占用
查看端口#
lsof -i tcp:port
将port换成被占用的端口(如:8080)
杀死进程:
kill -9 PID
(进程的PID,如50684),杀死对应的进程
演示;
#查看8081占用情况(LISTEN表示正在监听)
☁ ~ lsof -i tcp:8081
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Google 5129 yons 34u IPv4 0xdde0dc9d63598ae7 0t0 TCP 10.137.1.226:65464->10.137.1.226:sunproxyadmin (ESTABLISHED)
node 7916 yons 24u IPv4 0xdde0dc9d62053ec7 0t0 TCP *:sunproxyadmin (LISTEN)
node 7916 yons 150u IPv4 0xdde0dc9d59b45447 0t0 TCP 10.137.1.226:sunproxyadmin->10.137.1.226:65464 (ESTABLISHED)
#杀死对应的PID
☁ ~ kill -9 7916
#查看8081端口占用情况
☁ ~ lsof -i tcp:8081
#没有占用了
☁ ~
#端口占用进程已经被杀死