Image source: dockerize.io

One of the great things about developing Rails applications is that you don’t have to restart the server to test every change that you have made in your code. Still, there are cases when you may need to restart the server, but may face troubles trying to stop it, especially if you have your project server is started as a demon.

If you have a Rails project deployed at a remote server and have it running as a daemon, chances are that you may have sometimes the need to restart the server, which is not as trivial as when the server is running as long as you do not close the shell window.

If you need to stop Rails server in such cases, or in any other cases in general, then here is a command that can be helpful for you.

If your project is running on a Linux operating system, then you need to execute the following:

pkill -9 ruby

This will cause the server to stop. Most likely, you will have to run it with administrative privileges, which means that you need to add the part sudo in front, namely:

sudo pkill -9 ruby

After you execute this, your server should be stopped and now you can run the migrations, install new gems, or change any configurations that you need before you start the server again. 

I hope this quick tip helps you out.