如何修复“错误:监听 EADDRINUSE:地址已在使用 :::5000”“错误”事件

问题描述 投票:0回答:1
node:events:495
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::5000
    at Server.setupListenHandle [as _listen2] (node:net:1817:16)
    at listenInCluster (node:net:1865:12)
    at Server.listen (node:net:1953:7)
    at Function.listen (/Users/parthsojitra/Desktop/Final_SMCar/Final_SMCar/Final_SMCar/SM_Car-API/node_modules/express/lib/application.js:635:24)
    at Object.<anonymous> (/Users/parthsojitra/Desktop/Final_SMCar/Final_SMCar/Final_SMCar/SM_Car-API/index.js:50:5)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
Emitted 'error' event on Server instance at:
    at emitErrorNT (node:net:1844:8)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'EADDRINUSE',
  errno: -48,
  syscall: 'listen',
  address: '::',
  port: 5000
}

告诉我该怎么做

javascript node.js error-handling xampp mern
1个回答
1
投票

“EADDRINUSE”代表 Error Address 已正在使用 - 这意味着您尝试侦听的地址(主机 + 端口)已在使用中。

要搜索 Linux 上哪个进程正在使用端口,您可以使用:

sudo ss -lptn 'sport = :5000'

如果您使用的是 Windows,它可能也适用于 MacOS - 如何找出哪个进程正在 Windows 上的 TCP 或 UDP 端口上侦听?

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