1

I have made some changes to various files, and need to shut down and then restart the server to see them. I am using the Cloud9 railstutorial environment. But I keep getting the same error - "A server is already running". Please see below:

darrenbrett:~/workspace/sample_app (filling-in-layout) $ rails server -b $IP -p $PORT
=> Booting WEBrick
=> Rails 4.2.2 application starting in development on http://0.0.0.0:8080
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server

A server is already running. Check /home/ubuntu/workspace/sample_app/tmp/pids/server.pid.
Exiting
darrenbrett:~/workspace/sample_app (filling-in-layout) $ 
K M Rakibul Islam
  • 33,760
  • 12
  • 89
  • 110
Muirik
  • 6,049
  • 7
  • 58
  • 116

3 Answers3

3

Find out the process id (PID) first:

$ lsof -wni tcp:8080

This will give you something like this:

$ lsof -wni tcp:8080 

COMMAND   PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ruby    59656 rislam   14u  IPv6 0xa86b8563672ef037      0t0  TCP [::1]:http-alt (LISTEN)

Then, kill the process with PID = 59656 (for example, it will be different for you):

$ kill -9 59656

This should solve your problem.

You can also use the following command to kill all running apps that has rails in the name:

killall -9 rails

Sometimes, this is very effective when the first command does not do the trick.

K M Rakibul Islam
  • 33,760
  • 12
  • 89
  • 110
0

It sounds like you either have an orphaned server process running, or you have multiple applications in the same environment and you're running the server for another one and it's bound to the same port. I'm guessing the former.

Run ps -fe | grep rails. You should see something like 501 35861 2428 0 1:55PM ttys012 0:04.00 /your_file_path/ruby bin/rails server

Grab the process id (in the case of the example, it's 35861), and run kill -9 35861. Then try to start your server again.

elements
  • 1,047
  • 2
  • 9
  • 21
0

The easiest way I found to kill that server is to click on the suggested file in the line:

A server is already running. Check /home/ubuntu/workspace/sample_app/tmp/pids/server.pid

That opens the file containing a number, the process id you're looking for.

Example

43029

In the terminal window use "kill" via that same process id and restart the server.

kill -15 43029
rails server -b $IP -p $PORT