Freeing a port that's already in use

When running multiple servers, you may encounter the error:

> Error: Address already in use
> Error: listen EADDRINUSE

The error comes from trying to start a server when there’s already a running process bound to that port.

You have 2 options:

  1. You can start your server on a different port.
  2. Or you can free the current port by killing the process associated with it.

Of course, if you choose the second option, make sure it’s not running anything important.


To kill processes associated with port 8888:

# Mac
$ sudo lsof -t -i tcp:8888 | xargs kill -9

# Linux
$ fuser -k 8888/tcp