matt batista    about    contact    archive    feed

Port already in use? Let's kill it

While working on a project involving Rack + HTTP, I came across this error telling me that I am trying to access a port (localhost:3000) that is already in use.

My server was still listening on that port, it never finished. In order to use that port again, pop open your terminal and type this:

$ lsof -wni tcp:3000

After you hit enter, you’ll see a list of any processes being used by (in this case), port 3000.

There’s a PID (process identifier) number column that you’ll need for the final step of actually killing the process and open up the port for use again.

With your PID number in hand, you just need to type this into your terminal:

$ kill -9 PID

(That PID above will be an actual number)