DEV Community

Uriel
Uriel

Posted on

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.

Top comments (3)

Collapse
 
uriel_hedz profile image
Uriel

Hello, community! English is not my native language, so If you find a typo or a grammar mistake that Grammarly failed to find, feel free to correct me so I can fix the article!

Thanks!

Collapse
 
spencertweedy profile image
Spencer Tweedy

Lifesaver.

Collapse
 
suda2103 profile image
SuDa2103

More than 18 months after you wrote this but still so helpful. Saved me some unnecessary stress haha. Thanks!