Daniel
Daniel

Reputation: 1414

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

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?

Upvotes: 8

Views: 15779

Answers (3)

theterminalguy
theterminalguy

Reputation: 1941

If you don't know the exact PID, rails usually saves it in tmp/pids/server.pid So you can stop the rails server using

kill -9  $(cat tmp/pids/server.pid) 

Upvotes: 0

K M Rakibul Islam
K M Rakibul Islam

Reputation: 34328

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

Upvotes: 20

hylian
hylian

Reputation: 560

In the terminal window, Ctrl + C will stop the server running.

Upvotes: 0

Related Questions