首页 > 解决方案 > 端口未释放(nodemon)

问题描述

我正在使用 nodemon 重新加载我的服务器,但是当我保存文件时它会抛出一个错误,它说该端口已经被另一个进程使用。

这是错误:

events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::3000
    at Server.setupListenHandle [as _listen2] (net.js:1280:14)
    at listenInCluster (net.js:1328:12)
    at Server.listen (net.js:1415:7)
    at Function.listen (/home/yamil/code/tasksApp/node_modules/express/lib/application.js:618:24)
    at Object.<anonymous> (/home/yamil/code/tasksApp/index.js:23:5)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
Emitted 'error' event at:
    at emitErrorNT (net.js:1307:8)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
[nodemon] app crashed - waiting for file changes before starting...

pd:我使用的是 Ubuntu 20.04.2

标签: javascriptnode.jsubuntunodemon

解决方案


使用此命令终止侦听端口的所有程序:

lsof -ti tcp:3000 | xargs kill

推荐阅读