July 31, 2018

How to handle address already in use error

You attempted to start up a server, only to be confronted with the following error:

Address already in use - bind(2) for "0.0.0.0" port 3000 (Errno::EADDRINUSE)

What do you do?

  1. Figure out what service is using that address port.

To see what's running on port 3000, run:

lsof -i tcp:3000

That should return a result that looks similar like this:

COMMAND    PID   USER     FD   TYPE        DEVICE         SIZE/OFF  NODE NAME
com.docke xx783 username   18u  IPv4 0xblahblahblahblah      0t0     TCP *:hbci (LISTEN)
  1. Kill the service
sudo kill -9 PID

OR:

If you don't want to kill the server, start the server on a new port.