MacOS Sierra 所有端口都在使用中吗?

MacOS Sierra 所有端口都在使用中吗?

我正在尝试运行 webpack-dev-server,无论我使用哪个端口,我都会得到EADDRINUSE。如果我lsof没有发现任何正在使用该端口。

知道这里可能是什么问题吗?是否需要某种配置才能在 Mac 上本地托管内容?..我在 CentOS 和 Windows 7 上都可以正常工作。

Project is running at http://0.0.0.0:4040/
webpack output is served from /    
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE 0.0.0.0:4040
    at Object.exports._errnoException (util.js:1020:11)
    at exports._exceptionWithHostPort (util.js:1043:20)
    at Server._listen2 (net.js:1258:14)
    at listen (net.js:1294:10)
    at net.js:1404:9
    at _combinedTickCallback (internal/process/next_tick.js:83:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
    at Module.runMain (module.js:606:11)
    at run (bootstrap_node.js:389:7)
    at startup (bootstrap_node.js:149:9)

OSXDT8BDY3Hs-Mac-mini:cell-feature-search brandon$ lsof -Pn -i4
COMMAND    PID    USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
UserEvent  294 brandon    4u  IPv4 0x30b113a2f9275acf      0t0  UDP *:*
identitys  314 brandon   20u  IPv4 0x30b113a2f9274eef      0t0  UDP *:*
sharingd   331 brandon    4u  IPv4 0x30b113a2f9f5e60f      0t0  UDP *:*
sharingd   331 brandon    8u  IPv4 0x30b113a2f9f5d30f      0t0  UDP *:*
sharingd   331 brandon    9u  IPv4 0x30b113a2f9f5eacf      0t0  UDP *:*
sharingd   331 brandon   10u  IPv4 0x30b113a2f9f5ce4f      0t0  UDP *:*
sharingd   331 brandon   11u  IPv4 0x30b113a2f9f5f1ef      0t0  UDP *:*
SystemUIS  730 brandon   11u  IPv4 0x30b113a2f927644f      0t0  UDP *:*
SystemUIS  730 brandon   12u  IPv4 0x30b113a2f9274a2f      0t0  UDP *:*
SystemUIS  730 brandon   15u  IPv4 0x30b113a2f927456f      0t0  UDP *:62631
SystemUIS  730 brandon   16u  IPv4 0x30b113a2f927702f      0t0  UDP *:*
SystemUIS  730 brandon   18u  IPv4 0x30b113a2ebc8fe6f      0t0  UDP *:*
Finder     731 brandon   17u  IPv4 0x30b113a2ebc8b26f      0t0  UDP *:*
WiFiProxy  750 brandon    5u  IPv4 0x30b113a2ebc9032f      0t0  UDP *:*
WiFiAgent  797 brandon    5u  IPv4 0x30b113a2f9275d2f      0t0  UDP *:*
eapolclie  890 brandon    3u  IPv4 0x30b113a2f9f5c72f      0t0  UDP *:*
ARDAgent  1245 brandon    8u  IPv4 0x30b113a2ebc8f02f      0t0  UDP *:3283
Google    2139 brandon   60u  IPv4 0x30b113a2ebc8fc0f      0t0  UDP *:*
Google    2139 brandon  121u  IPv4 0x30b113a2edad67e7      0t0  TCP 10.128.202.154:50991->151.101.65.69:443 (ESTABLISHED)
Google    2139 brandon  125u  IPv4 0x30b113a2eeec89d7      0t0  TCP 10.128.202.154:51219->63.251.109.83:443 (CLOSED)
Google    2139 brandon  129u  IPv4 0x30b113a2ef0202cf      0t0  TCP 10.128.202.154:51220->198.252.206.25:443 (ESTABLISHED)
Google    2139 brandon  130u  IPv4 0x30b113a2f85847e7      0t0  TCP 10.128.202.154:50944->10.128.200.65:8009 (ESTABLISHED)
Google    2139 brandon  144u  IPv4 0x30b113a2edad79d7      0t0  TCP 10.128.202.154:50994->23.44.160.143:443 (ESTABLISHED)
Google    2139 brandon  148u  IPv4 0x30b113a2ed2f7bc7      0t0  TCP 10.128.202.154:50997->23.44.160.143:443 (ESTABLISHED)
Google    2139 brandon  150u  IPv4 0x30b113a2ed2e5db7      0t0  TCP 10.128.202.154:50996->54.225.188.155:443 (CLOSED)
Google    2139 brandon  156u  IPv4 0x30b113a2eeec9bc7      0t0  TCP 10.128.202.154:51187->12.129.210.52:443 (CLOSED)
Google    2139 brandon  169u  IPv4 0x30b113a2ef0ca0df      0t0  TCP 10.128.202.154:51180->54.209.13.204:443 (CLOSED)
Google    2139 brandon  174u  IPv4 0x30b113a2ed2652cf      0t0  TCP 10.128.202.154:51000->104.125.212.239:443 (ESTABLISHED)
Google    2139 brandon  182u  IPv4 0x30b113a2ec77c2cf      0t0  TCP 10.128.202.154:51006->104.16.2.9:443 (ESTABLISHED)
Google    2139 brandon  183u  IPv4 0x30b113a2ed2f57e7      0t0  TCP 10.128.202.154:51008->23.44.160.11:443 (ESTABLISHED)
Google    2139 brandon  185u  IPv4 0x30b113a2ec77cbc7      0t0  TCP 10.128.202.154:51009->23.44.160.11:443 (ESTABLISHED)
Google    2139 brandon  187u  IPv4 0x30b113a2ef0cbbc7      0t0  TCP 10.128.202.154:51068->172.217.3.206:80 (CLOSED)
Google    2139 brandon  188u  IPv4 0x30b113a2eeeb6bc7      0t0  TCP 10.128.202.154:51069->173.194.56.244:80 (CLOSED)
Google    2139 brandon  190u  IPv4 0x30b113a2eeeb59d7      0t0  TCP 10.128.202.154:51016->74.121.133.33:443 (ESTABLISHED)
Google    2139 brandon  193u  IPv4 0x30b113a2eeeb47e7      0t0  TCP 10.128.202.154:51070->173.194.56.119:80 (CLOSED)
Google    2139 brandon  197u  IPv4 0x30b113a2f7aa8db7      0t0  TCP 10.128.202.154:51149->104.16.112.18:443 (ESTABLISHED)
Google    2139 brandon  215u  IPv4 0x30b113a2ed2e27e7      0t0  TCP 10.128.202.154:51091->23.21.52.164:443 (CLOSED)

答案1

我有几个想法,但这些只是有根据的猜测。尝试将 IP 地址更改为其他地址。由于 Mac OS 喜欢采取奇怪的安全措施,将其设置为 127.0.0.1 而不是 0.0.0.0 可能会有所不同

您的 lsof 命令仅查看 IPv4,请同时检查 IPv6 连接。我相信 Mac OS X 有 ss 命令:

ss -l src :4040

我要做的最后一件事是尝试看看当您尝试 telnet 进入该端口时会发生什么。任何类型的响应都告诉您有东西在监听,但希望它能提供更多线索。

答案2

正在使用的“地址”可能是端口号,而不是 IPv4 地址。它可能由 root 或其他用户使用。您忘记了sudo您的lsof,所以它只显示您自己的进程。也许您或 launchd 或以其他真实用户或系统帐户启动的东西,webpack-dev-server所以现在有一个您看不到的副本正在运行,并且它保持监听器在 *:4040/TCP 上打开。rootnobody_www

相关内容