Error: bind EADDRINUSE null:80 in node.js
Error: bind EADDRINUSE null:80 in node.js
当我用 npm start 执行程序时,出现:
Error: bind EADDRINUSE null:80
at Object.exports._errnoException (util.js:896:11)
at exports._exceptionWithHostPort (util.js:919:20)
at cb (net.js:1311:16)
at rr (cluster.js:620:14)
at Worker.<anonymous> (cluster.js:590:9)
at process.<anonymous> (cluster.js:750:8)
at emitTwo (events.js:111:20)
at process.emit (events.js:191:7)
at handleMessage (internal/child_process.js:718:10)
at Pipe.channel.onread (internal/child_process.js:444:11)
CLUSTER: Worker 177 disconnected from the cluster.
CLUSTER: Worker 177 died with exit code 1 (null)
CLUSTER: Worker 181 started
events.js:160
throw er; // Unhandled 'error' event
如果将端口从 80 更改为 8080,程序会执行,但不要连接到 api.localhost:3000
作为特权用户,您应该能够使用以下命令列出引用 TCP 端口 80 的进程:
netstat -plant | grep LISTENING | grep :80
在右栏中,您应该找到一个进程名称和相应的 PID,这将指示谁正在侦听该端口。
使用基于 debian 或 el7 的系统,如今,您通常需要安装 net-tools
软件包,提供 netstat
命令。
根据 Gregory NEUT 的建议,您可能没有足够的权限绑定 :80。尽管 AFAIR,在那种情况下,您应该会收到 EACCESS
错误。而 EADDRESSINUSE
表示其他应用程序已经在侦听 TCP:80
。它甚至可能是您应用程序的先前副本,运行 在后台。
EADDRINUSE
表示“E错误 ADDress already IN USE”
所以你可能有另一个进程在监听 80 端口
在 linux 上,您可以使用命令 netstat -a | grep LISTENING | grep 80
列出正在使用的端口
当我用 npm start 执行程序时,出现:
Error: bind EADDRINUSE null:80
at Object.exports._errnoException (util.js:896:11)
at exports._exceptionWithHostPort (util.js:919:20)
at cb (net.js:1311:16)
at rr (cluster.js:620:14)
at Worker.<anonymous> (cluster.js:590:9)
at process.<anonymous> (cluster.js:750:8)
at emitTwo (events.js:111:20)
at process.emit (events.js:191:7)
at handleMessage (internal/child_process.js:718:10)
at Pipe.channel.onread (internal/child_process.js:444:11)
CLUSTER: Worker 177 disconnected from the cluster.
CLUSTER: Worker 177 died with exit code 1 (null)
CLUSTER: Worker 181 started
events.js:160
throw er; // Unhandled 'error' event
如果将端口从 80 更改为 8080,程序会执行,但不要连接到 api.localhost:3000
作为特权用户,您应该能够使用以下命令列出引用 TCP 端口 80 的进程:
netstat -plant | grep LISTENING | grep :80
在右栏中,您应该找到一个进程名称和相应的 PID,这将指示谁正在侦听该端口。
使用基于 debian 或 el7 的系统,如今,您通常需要安装 net-tools
软件包,提供 netstat
命令。
根据 Gregory NEUT 的建议,您可能没有足够的权限绑定 :80。尽管 AFAIR,在那种情况下,您应该会收到 EACCESS
错误。而 EADDRESSINUSE
表示其他应用程序已经在侦听 TCP:80
。它甚至可能是您应用程序的先前副本,运行 在后台。
EADDRINUSE
表示“E错误 ADDress already IN USE”
所以你可能有另一个进程在监听 80 端口
在 linux 上,您可以使用命令 netstat -a | grep LISTENING | grep 80