【发布时间】:2015-01-31 20:55:21
【问题描述】:
如何在 Mac OS X 上查看哪个进程正在侦听端口 8001?
我尝试了几个命令:
lsof -i | grep LISTEN
qbittorre 321 user 26u IPv4 0xc8e6037f28270c31 0t0 TCP *:6881 (LISTEN)
qbittorre 321 user 27u IPv6 0xc8e6037f216348e1 0t0 TCP *:6881 (LISTEN)
mysqld 14131 user 10u IPv4 0xc8e6037f3218da91 0t0 TCP *:mysql (LISTEN)
httpd 14133 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
httpd 14135 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
httpd 14136 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
httpd 14137 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
httpd 14138 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
httpd 14139 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
httpd 14148 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
httpd 14149 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
httpd 14150 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
Skype 14543 user 57u IPv4 0xc8e6037f324f9a91 0t0 TCP *:18666 (LISTEN)
java 24640 user 68u IPv6 0xc8e6037f3295a3e1 0t0 TCP *:http-alt (LISTEN)
java 24640 user 73u IPv6 0xc8e6037f32958fe1 0t0 TCP *:8009 (LISTEN)
java 24640 user 101u IPv6 0xc8e6037f32959ee1 0t0 TCP localhost:8005 (LISTEN)
lsof:
sudo lsof -nPi -sTCP:LISTEN | grep 8001
没有找到
网络统计:
netstat -a | grep 8001
没有找到
我知道该端口正在被某人使用,因为我正在尝试将 Emacs simple-httpd 默认 httpd-port 从 8080(默认)更改为 8001,但它失败了:
Warning (initialization): An error occurred while loading `/Users/user/.emacs':
File error: Cannot bind server socket, address already in use
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
我该如何解决?我也尝试将端口设置为 8002,但同样的问题,并没有发现哪个进程正在侦听端口 8002。
问题的根源是什么?
编辑:使用 nmap 我发现端口 8001 被 vcom-tunnel 服务使用,它是一个封闭端口,而端口 8002 被 teradataordbms 并且也关闭了。
这些服务的用途是什么?我可以禁用它们并使用它们占用的端口吗?
【问题讨论】:
-
我试过
sudo lsof -n -i4TCP:8001 | grep LISTEN但没有。好像没有使用8001端口,但我不明白为什么我一直收到emacs simple-httpd错误... -
请检查我的编辑!
-
感谢您的链接!无论如何,自从我上次发表评论以来,我已经解决了,只是没有更新。
lsof -i:portnumber工作。
标签: macos emacs port netstat lsof