Getting Freaked Out By Node EADDRINUSE (Address Already in Use) Error?

Baraka Mahili
2 min readJan 23, 2019

--

VSCode terminal showing the error

For some weird reasons, EADDRINUSE just shows up and freaks me out. I know I am not the only one and just decided to put this here on Medium for my future reference and hopefully, someone else gets help from it.

Error: listen EADDRINUSE: address already in use :::5000
[0] at Server.setupListenHandle [as _listen2] (net.js:1290:14)
[0] at listenInCluster (net.js:1338:12)
[0] at Server.listen (net.js:1425:7)

After looking for a few sources online, I came across a few commands to get this time-killer killed.

In your terminal, find which processes are running by typing:

ps aux | grep node

You get something similar to this:

barakamahili 26070 0.0 0.2 4623092 36580 ?? S 9:14AM 0:00.71 node /usr/local/bin/nodemon server
barakamahili 25968 0.0 0.3 4674152 55112 ?? S 9:14AM 0:01.01 /usr/local/bin/node server.js
barakamahili 25951 0.0 1.6 7120044 266748 ?? S 9:11AM 0:12.21

Next, find which process is hijacking your precious port by typing:

lsof -n -i:[port-number] 

As in the error example above…(Error: listen EADDRINUSE: address already in use :::5000), my port is 5000 so I typed:

lsof -n -i:5000

You get something like this:

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 25968 barakamahili 22u IPv6 ****** 0t0 TCP *:commplex-main (LISTEN)

Then kill that process by typing:

kill -9 [port number]

This is what I typed:

kill -9 25968

And that should do it…at least it did it for me :)

#HappyCoding

Thanks

--

--