How do you stop a rails server from the command line?

12,873

Way 1: Just type: Ctrl + C in the terminal where your server is running.

Way 2: Another way of doing it:

In your terminal to find out the PID of the process:

$ lsof -wni tcp:3000

Then, kill the process:

$ kill -9 PID

Way 3: You can also use the following command to kill all running apps with rails in the name:

killall -9 rails
Share:
12,873
Daniel
Author by

Daniel

Updated on June 04, 2022

Comments

  • Daniel
    Daniel almost 2 years

    I had a weird incidence where I closed my terminal, but the server kept running. When I tried to run the server again I got a message that the server was still running. How could I stop the server through the command line?

  • Daniel
    Daniel over 8 years
    I know to use ctrl + c, but the window was already closed. Your second recommendation worked. Thank you very much!
  • K M Rakibul Islam
    K M Rakibul Islam over 8 years
    You're most welcome. Glad it helped you solve your problem :-)
  • Low
    Low over 3 years
    I had the issue where the server said it was already running and I had no way to Ctrl+C out of it. This helped, thanks!
  • Kevin
    Kevin over 3 years
    For me, killall rails did not work, but killall ruby did.