How to stop rails server?

How to stop rails server?

Play this article

A lot of times you will leave the rails server running in the background and face this TCPServer Error: Address already in use

Now normally you want to use Ctrl+C to shutdown the server,but there are other ways too.

You can get the PID of the process in the tmp/pids directory of your Rails app or use

lsof -wni tcp:3000

or if you have multiple processes running

ps aux | grep rails

to find the one you need and use the PID number to kill using

kill -9 PID.

To kill all running rails process

pkill -9 rails

Last but not the least use

ps aux|grep 'rails'|grep -v 'grep'|awk '{ print $2 }'|xargs kill-9

to kill any rails process. Replace 'rails' with anything else to kill any other processes.