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?
You should disable AirPlay on your mac. Because macOS Monterey started to listen to port 5000 and 8000.
System Preferences > Sharing > untick AirPlay Receiver
For macOS Ventura:
System Settings > General > disable Airplay Receiver
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With