节点EADDRINUSE(地址已在使用中)错误

我的MacBook Pro偶尔会出现故障,并且整个过程都很糟糕。 当我从事出色的debugger.html项目时,通常会发生这种情况。 我试图启动调试器的服务器端,突然发现类似于以下错误,导致该过程从那时开始不启动:

Error: listen EADDRINUSE 0.0.0.0:9000
    at Object._errnoException (util.js:1026:11)
    at _exceptionWithHostPort (util.js:1049:20)
    at Server.setupListenHandle [as _listen2] (net.js:1343:14)
    at listenInCluster (net.js:1391:12)
    at doListen (net.js:1500:7)
    at _combinedTickCallback (internal/process/next_tick.js:141:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
    at Function.Module.runMain (module.js:667:11)
    at startup (bootstrap_node.js:201:16)
    at bootstrap_node.js:626:3

解决此问题的最佳方法是杀死为流氓任务运行的Node.js进程。 首先找到所有节点进程的列表:

ps aux | grep node

您会看到类似于以下内容的清单:

davidwalsh       12413   0.0  0.0  2592088   3888   ??  S     7:38PM   0:20.45 /Users/davidwalsh/Projects/debugger.html/node_modules/flow-bin/flow-osx-v0.52.0/flow
davidwalsh       12412   0.0  0.0 29739356   2372   ??  S     7:38PM   0:00.12 /Users/davidwalsh/Projects/debugger.html/node_modules/flow-bin/flow-osx-v0.52.0/flow
davidwalsh       12411   0.0  0.0 29732188   2372   ??  S     7:38PM   0:00.07 /Users/davidwalsh/Projects/debugger.html/node_modules/flow-bin/flow-osx-v0.52.0/flow
davidwalsh       12410   0.0  0.0 29732188   2372   ??  S     7:38PM   0:00.07 /Users/davidwalsh/Projects/debugger.html/node_modules/flow-bin/flow-osx-v0.52.0/flow
davidwalsh       12409   0.0  0.0 29731164   2372   ??  S     7:38PM   0:00.06 /Users/davidwalsh/Projects/debugger.html/node_modules/flow-bin/flow-osx-v0.52.0/flow

标识恶意进程时,请使用kill命令以及进程号将其删除:

#kill -9 {process_number}
kill -9 12413

随着进程的终止,您现在可以正常启动服务器了!

翻译自: https://davidwalsh.name/node-eaddrinuse

你可能感兴趣的:(节点EADDRINUSE(地址已在使用中)错误)