Killing all instances of Ruby on Rails running on a certain port

How to find and stop all instances of Rails running on a specific port

I was having a hard time getting my Rails webserver to restart after it having a bit of a hissy fit. The process to handle most apps when this happens is to locate the PID (Process ID) of the thing that is broken and kill it.

An easy way to do this with Rails is to type the following into your Terminal;

lsof -wni tcp:3000

Which looks for all processes running on port 3000 (the most common port for things like Webrick and Thin to run on) and returns them all as a table.

One of the columns of the table will be the PID for the process, copy it and paste it into the following line which will go into your Terminal;

kill -9 PID

Replacing 'PID' with the PID you just copied.

This will kill all processes relating to that PID, once this is done you should be good to go ahead and restart your rails server.

Recent posts View all

Productivity

5 ways to speed up your software development

I love feeling like I am speeding through development tasks, here are five things that can help speed up your software development

Accessibility SEO

The main reasons why we shouldn't use click here as link text

There are many reasons why we shouldn't use click here or similar as link text, let's go through them