How to kill a stuck Rails server

uriel_hedz

Uriel

Posted on April 27, 2020

How to kill a stuck Rails server

When the Ctrl + C shortcut has abandoned you there's a simple way to kill your Rails server if you are under a UNIX OS, say MacOs or any Linux distribution.

The first thing you need is to find the PID of the process that is running the rails server, for it, go ahead and open the file under the following location: YOUR_PROJECT/tmp/pids/server.pid

Inside this file, you will find a number, that's the PID you are looking for, just copy it to use it in the kill command that we will use to kill the server.

Once you have the PID of the process, you may use the kill command on your terminal to end the rails server:

kill -9 <your-pid>

Alternatively, if you can't find your PID under the mentioned location, you can look for the processes running under the 3000 port to find the proper ID, depending on your OS, the command to find out what processes are running under a given port may differ.

And that's it, whether it's because your code went under a loop, or because you closed your VS Code editor without ending the rails server, this alternative will help you kill your rails server no matter what.

💖 💪 🙅 🚩
uriel_hedz
Uriel

Posted on April 27, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related