Rails how to solve 'A server is already running.' problem

Lorenzo Sinisi bio photo By Lorenzo Sinisi Comment

If you find yourself in this situation like ‘A server is already running’ often you know how annoying this is. This happens depending on you terminal settings or when you have many tabs open and you don’t know where Rails is running, but you wanna stop the server. And all the times you get the error ‘A server is already running.’.

How to fix that:

=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
A server is already running. Check /tmp/pids/server.pid.
Exiting

Option 1:

cat /tmp/pids/server.pid
kill -9 PID

But this is boring. And you have to do it all the times. I created a shortcut for that, it is called ‘shutup’.

Introducing Shutup

It is a gem that reads the current process id in the current Rails folder and sends a ‘kill -9 PID’ to the machine killing the it.

Installation of Shutup

$ cd # in the project folder
$ gem install shutup

Installation (if using rvm)

$ cd # in the project folder
$ rvm @global do gem install shutup

Usage

After installing the gem run:

$ cd # in the project folder
$ shutup

Test it

TEST IT: try to start the Rails app, open a new terminal window and then type:

$ shutup

To see how this gem kills the current process.

Let me know if you find this useful.

comments powered by Disqus