I am new to rails and I am using an ubuntu machine and the rubymine IDE. The problem is that I am unable to stop the rails server. I tried to stop the server by killing the rails process. But, when I run pgrep -l rails
, no such process is found. So, I am only able to kill ruby processes, but, the server won't stop.
I tried ./script/server stop
(since I started it by running ./script/server start
), but, that didn't work. Googling around and finding some stackoverflow posts, I tried to change the localhost port's listening port but without success. Could someone help?
One way to shut down a rogue server is with the kill command. For the PID output above, you could kill the corresponding stuck server using kill 42612 . And if that didn't work, you could try kill -9 42612 .
For Rails 5.0 and above, you can use this command Use ctrl+c to shutdown your Webrick Server.
To exit the console, type: quit .
It says 'To stop, click Ctrl+c '.
You can use other ports like the following:
rails server -p 3001
Normally in your terminal you can try Ctrl + C
to shutdown the server.
The other way to kill the Ruby on Rails default server (which is WEBrick
) is:
kill -INT $(cat tmp/pids/server.pid)
In your terminal to find out the PID of the process:
$ lsof -wni tcp:3000
Then, use the number in the PID column to kill the process:
For example:
$ kill -9 PID
And some of the other answers i found is:
To stop the rails server while it's running, press:
CTRL-C CTRL-Z
You will get control back to bash
. Then type (without the $
):
$ fg
And this will go back into the process, and then quit out of Rails s
properly.
It's a little annoying, but this sure beats killing the process manually. It's not too bad and it's the best I could figure out.
You can use killall -9 rails
to kill all running apps with "rails
" in the name.
killall -9 rails
you can use grep command in following way,
ps aux | grep rails
and then
kill -9 {process_id}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With