Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 4sskick/26ae70158cf4acabb1ae48c57535f9f7 to your computer and use it in GitHub Desktop.
Save 4sskick/26ae70158cf4acabb1ae48c57535f9f7 to your computer and use it in GitHub Desktop.
Error: listen EADDRINUSE: address already in use

so this issue will clearly tell you that the address or port is in use by another program or task service process. The error will tell you oike this,

Error: listen EADDRINUSE: address already in use 127.0.0.1:9323
    at Server.setupListenHandle [as _listen2] (node:net:1372:16)
    at listenInCluster (node:net:1420:12)
    at GetAddrInfoReqWrap.doListen (node:net:1559:7)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:73:8) {
  code: 'EADDRINUSE',
  errno: -4091,
  syscall: 'listen',
  address: '127.0.0.1',
  port: 9323
}

To resolve the issue which come in our mind would be kill the programs or tasks that are using the same address or port we wanna use. But we don't know which program or task is that, so to identify

Mac/Linux:

sudo lsof -i :9323<port_you_wanna_use>

The command will give you list of processes using port 9323, along with their PID (Process ID).

Windows:

netstat -ano | findstr :9323<port_you_wanna_use>

The command will give you list of process using port you defined, like this one

PS C:\Users\YourUser\YourProject> netstat -ano|findstr "PID :9323"
Proto Local Address Foreign Address State PID TCP 127.0.0.1:9323 0.0.0.0:0 LISTENING 27924

After you have those bunch of list by hit the command, you need to kill their process by PID

Mac/Linux:

Suppose the PID you found was 27924, you’d type:

kill -9 27924

Windows:

Again, if the PID was 27924, you’d type:

taskkill /PID 27924 /F

Be mindful of the ports your applications are using and ensure they're appropriately closed when you're done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment