Nikita Kazakov
Nikita Kazakov
~1 min read


I can’t be the only one who occasionally tries to start rails server and gets:

Ctrl-C to shutdown server
A server is already running. Check ./tmp/pids/

Open your terminal and type in (this command will unfortunately close down your browser windows as well.)

kill -9 $(lsof -i tcp:3000 -t)

Now run rails server and it will succeed.

Creating a Ruby File

Because I won’t remember this cryptic looking command, I like to create a separate ruby-kill.rb file right in my Rails project directory.

Add this inside the ruby-kill.rb:

system("kill -9 $(lsof -i tcp:3000 -t)")

Run this file whenever you need to kill the rails server.