Kill Rails Server : A How-to Guide

· 1 min read
Kill Rails Server : A How-to Guide

How to kill your Rails server ? This could happen if your Rails server is buggy, and restart is not possible.


Short answer


If you local Rails server is running on port 3000, you have first to discover what PID is used :


The column that matters is "PID". The relevant number is 51195 here. On your computer it will probably be another number, but for our example, the solution will be


Replace 51195 by your own PID and that's it.


Alternative : use the shutup gem


If this is a problem that happends too frequently, you can install a gem dedicated to this problem : shutup. Repository and documentation available here


Tutorial from scratch


If you want to test the problem "from scratch", here is a small tutorial. Ruby 3 and Rails 7 will be used.


Prerequisites


Install fresh new Rails app


Check everything is working by running


Side note The PID is actually displayed once in the verbose logging that appears right after you started the server.  Nici's Blog  above.