Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ROR + A server is already running. Check .../tmp/pids/server.pid. Exiting

In my Rails Project, I am trying to run two different servers at different port. But it fails by giving this error at console.

C:\Rails>rails s => Booting Mongrel => Rails 3.1.1 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:/Rails/tmp/pids/server.pid.Exiting 

Please check the updated answer.

like image 611
Rubyist Avatar asked Feb 28 '13 04:02

Rubyist


People also ask

How do you stop the server which is already running?

From the command line window where the Application Server is running, enter Ctrl-C .

How do I find my PID server?

Press Ctrl+Shift+Esc on the keyboard. Go to the Processes tab. Right-click the header of the table and select PID in the context menu.

What is PID in Rails?

pid file contains a single number: the PID (Process ID). The Rails Server uses this number to track the server's process.


2 Answers

After googling a lot, I just delete that file and restart the server. Then again system create that file, then again I delete that file. Now Server is running fine. And System generates another copy at the same place. But it is running well.

DELETE THAT FILE .... 

If you want to run two servers then it may again create trouble. So

Both commands are checking the default PID file location (tmp/pids/server.pid), so you're seeing this error. Try running multiple servers like so:

Server 1: bundle exec rails s  Server 2: bundle exec rails s -p 3001 -P tmp/pids/server2.pid 

Credit: https://stackoverflow.com/a/14446920/1376448

Thanks

UPDATE after Connor Leech comment about Forman Gem

Foreman can help manage multiple processes that your Rails app depends upon when running in development. It also provides an export command to move them into production.

like image 162
Rubyist Avatar answered Oct 19 '22 20:10

Rubyist


You can use netstat to know which process is holding the rails webserver, then you can kill the pid and start it over again, assuming that for some weird reason the server is not responding or running in background and you don't find another way to restart it..

netstat -plntu | grep 3000 tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN      7656/ruby 

The last column shows the PID and the process name, then you only need to do:

kill -9 7656 

and rails s to get it working again...

Hope it's useful

like image 21
kainlite Avatar answered Oct 19 '22 19:10

kainlite