Mac命令行关闭端口
========================
lsof -i:端口号
这里项目PefectTemplate占用了8181端口号,因此我输入的是lsof -i:8181
,可以看到PerfectTemplate的进程ID为1869。
kill PID
得到PID为1869后,我需要关闭端口,只需要使用kill 1869
即可。
| zhangsaidong@zhangsaidongs-MacBook-Pro PerfectTemplate % lsof -i:8181 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME Google 574 zhangsaidong 38u IPv4 0xe91302581543067 0t0 TCP localhost:56525->localhost:8181 (ESTABLISHED) Google 574 zhangsaidong 44u IPv4 0xe91302581f1b067 0t0 TCP localhost:56526->localhost:8181 (ESTABLISHED) PerfectTe 1869 zhangsaidong 3u IPv4 0xe91302587abea7f 0t0 TCP *:8181 (LISTEN) PerfectTe 1869 zhangsaidong 4u IPv4 0xe91302582798067 0t0 TCP localhost:8181->localhost:56525 (ESTABLISHED) PerfectTe 1869 zhangsaidong 5u IPv4 0xe91302579eaa807 0t0 TCP localhost:8181->localhost:56526 (ESTABLISHED) zhangsaidong@zhangsaidongs-MacBook-Pro PerfectTemplate % kill 1869
|
检查
关闭前
关闭后
至此端口被成功关闭。