一个进程可以占用多个端口。
查看某个进程占用哪些端口:
lsof -nP | grep TCP | grep -i 进程名
➜ cocos_creator lsof -nP | grep TCP | grep -i qq QQ 253 deng 24u IPv4 0xcf28a26f9c20c057 0t0 TCP 192.168.1.8:60167->123.151.10.164:80 (ESTABLISHED) QQ 253 deng 37u IPv4 0xcf28a26f78cc0357 0t0 TCP 127.0.0.1:4300 (LISTEN) QQ 253 deng 38u IPv4 0xcf28a26f893869d7 0t0 TCP 127.0.0.1:4301 (LISTEN) QQ 253 deng 43u IPv4 0xcf28a26f9c20c057 0t0 TCP 192.168.1.8:60167->123.151.10.164:80 (ESTABLISHED)
查看某个端口被哪个进程用:
lsof -i:端口
1 ➜ cocos_creator lsof -i:60167 2 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME 3 QQ 253 deng 24u IPv4 0xcf28a26f9c20c057 0t0 TCP bogon:60167->123.151.10.164:http (ESTABLISHED) 4 QQ 253 deng 43u IPv4 0xcf28a26f9c20c057 0t0 TCP bogon:60167->123.151.10.164:http (ESTABLISHED)
来源:https://www.cnblogs.com/dzqdzq/p/10890726.html