iiRosie1
iiRosie1

Reputation: 162

A server is already running

I'm currently using cloud 9 for this project. When I run it using rails server -b $IP -p $PORt it gives me this:

=> Booting Puma
=> Rails 5.0.0 application starting in development on http://0.0.0.0:8080
=> Run `rails server -h` for more startup options
A server is already running. Check /home/ubuntu/workspace/saasapp/tmp/pids/server.pid.
Exiting

Does anyone know how to fix this? I already tried closing and re-opening the tabs again, and stop running the run project button. The language is ruby-on-rails and I'm sort of a beginner.

Upvotes: 2

Views: 4770

Answers (3)

Jan Werkhoven
Jan Werkhoven

Reputation: 2953

This happens when you close the terminal tab before ending Rails.

To end Rails, find its process ID with lsof, then kill it:

lsof -i tcp:8080
[copy the PID]
kill -9 [paste PID]
bin/rails s

Alternatively, you can also find the process ID in Puma's temporary files using cat, then kill it:

kill -9 $(cat tmp/pids/server.pid)
bin/rails s

Upvotes: 2

Sweet_Cherry
Sweet_Cherry

Reputation: 333

The error is happening because you most likely started your server, then closed the terminal before closing the server. I also had that error, but what I did was that I clicked the memory cpu disk icon on the top right corner, then clicked restart, and re-ran my server, and it started. I'm not sure if it's the proper way, but I was following a tutorial and that's what they showed.

Upvotes: 2

RoRFan
RoRFan

Reputation: 424

Open this file: /home/ubuntu/workspace/saasapp/tmp/pids/server.pid as it states in the error.
The file should contain the process ID.
Copy the ID.
Open the terminal -> https://docs.c9.io/docs/terminal and run the command

sudo kill -9 {the copied ID}

Subsequently delete the ID from the server.pid file and try to start the server again

Upvotes: 0

Related Questions