I am trying to run a nodes app. I run node app.js
. When I do, I get this error:
node:events:346
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::5000
at Server.setupListenHandle [as _listen2] (node:net:1311:16)
at listenInCluster (node:net:1359:12)
at Server.listen (node:net:1446:7)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1338:8)
at processTicksAndRejections (node:internal/process/task_queues:81:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::',
port: 5000
}
I spent hours looking at possible solutions online but none have worked so far. Same codebase works great on a different machine. This error happens on Mac M1 chip.
Does anybody have any idea how to fix this?
I tried finding processes running on 5000, I tried to kill them etc... nothing worked so far. I am running node 15.14.0
.
I am on a M1 Chip
, running macOS Monterey
How can I fix this error?
CodePudding user response:
List all process on mac:
sudo lsof -PiTCP -sTCP:LISTEN
You will see a list of process and its ports. Choose the process PID on 5000 port or any other port in the error: EADDRINUSE: address already in use...
Finally kill it if it is not an important app for you
kill -9 1234
CodePudding user response:
Lee Jeonghyun was correct. The reason why kill -9 PID
would never work is because of this:
https://developer.apple.com/forums/thread/682332
Control Center on Monterey is listening on 5000 as well.
I changed the port number in my nodejs app and the app started working again.