Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't stop rails server

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?

like image 259
epsilones Avatar asked Feb 26 '13 11:02

epsilones


People also ask

How do you stop rails server forcefully?

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 .

How do you kill a running rails server?

For Rails 5.0 and above, you can use this command Use ctrl+c to shutdown your Webrick Server.

How do I get out of rails console?

To exit the console, type: quit .

How do I cancel my Puma server?

It says 'To stop, click Ctrl+c '.


2 Answers

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.

Updated answer:

You can use killall -9 rails to kill all running apps with "rails" in the name.

killall -9 rails

like image 66
Learner Avatar answered Sep 27 '22 20:09

Learner


you can use grep command in following way,

ps aux | grep rails 

and then

kill -9 {process_id}  
like image 21
maximus ツ Avatar answered Sep 27 '22 19:09

maximus ツ