无法在Mac OS X上找到正在侦听端口8001的进程

问题描述 投票:0回答:1

如何在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 |抓住8001

什么都没找到

netstat的:

netstat -a |抓住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使用,也是关闭的。

这些服务用于什么?我可以禁用它们并使用它们占用的端口吗?

macos emacs port netstat lsof
1个回答
0
投票

这不是答案,我只是改写这个问题:

  • 在给定端口上设置服务器失败,错误为Address already in use
  • lsof不报告该端口的任何监听器

这是shell日志,展示了这一点:

[1]$ python -m SimpleHTTPServer 3333 2>&1 | fgrep error
socket.error: [Errno 48] Address already in use
[2]$ sudo lsof -i TCP:3333
[3]$ echo $?
1

[1]:在端口3333上启动Web服务器失败,错误为Address already in use

[2]lsof没有报告任何人使用的3333港口

让我们生成流量以强制lsof检测端口的使用:在另一个终端打开一个telnet连接:

[1]$ telnet localhost 3333

现在回到你以前的终端,你会看到lsof找到你的端口:

[4]$ sudo lsof -n -P -i :3333
COMMAND   PID    USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
telnet  78142 loic    5u  IPv4 0x3fa2e8474ece6129      0t0  TCP 127.0.0.1:51855->127.0.0.1:3333 (ESTABLISHED)

有流量,但根据操作系统,只有连接的一端,发起者,仍然没有LISTENER

注意:在我的情况下,操作系统是macOS 10.13.3,但我也使用过以前版本的macOS / OSX

© www.soinside.com 2019 - 2024. All rights reserved.