Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I kill a rails webrick server?

When I try to start a server via rails s, I get the following error message:

C:\Users\Frankie\Documents\stocktracker>rails s
=> Booting WEBrick
=> Rails 3.2.8 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
A server is already running. Check C:/Users/Frankie/Documents/stocktracker/tmp/p
ids/server.pid.
Exiting

The number listed in server.pid is 8436.

How do I manually kill this process? How can I easily kill all webrick servers currently running?

like image 534
fbonetti Avatar asked Jan 09 '13 18:01

fbonetti


People also ask

How do I kill an existing Rails server?

Commanding it to die 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 server in Ruby on Rails?

So in doing research, I discovered I can kill any server with the following commands and instructions: lsof -i :<PORT NUMBER> (i.e. lsof -i :3000 ) Obtain the unique PID (process identifier) from lsof -i output. kill -QUIT <PID> (i.e. kill -QUIT 4091 )

How do I kill a running server?

If the process view is not already threaded by parent-child relation, then press Ctrl-T a few times until it is. You then should be able to see the webserver. Select it, and then right-click on it. Select "Kill Process Tree" to forcibly kill the webserver.


2 Answers

You can use the taskkill utility.

taskkill /PID 8436
like image 159
Daniel Evans Avatar answered Oct 21 '22 19:10

Daniel Evans


If you are using iTerm2 on OSX you can open Toolbelt => ShowToolbelt, select ruby pid 8436 then click send signal to kill it. Occasionally task kill doesn't work for me.

Also, you can ps -aux | grep rails to find the pid. and then kill like the other answers recommend.

like image 32
Chase Avatar answered Oct 21 '22 19:10

Chase