Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails - A server is already running

I have a problem when I want to start my server in my terminal I do rail s or rails server and there is an error A server is already running. Check /Users/baptiste/code/BaptisteB/my-app/tmp/pids/server.pid.

What does it mean? And why it is present?

I delete it and when I check my localhost:3000. There is nothing. I have to log off my laptop and turn on it to begin to work.

How could I stop this error? Maybe I can destroy it with a command. Thank you for your help.

like image 959
Basti B. Avatar asked Feb 07 '23 07:02

Basti B.


1 Answers

Try to run below command on your terminal and you will get pid (process id)

lsof -wni tcp:3000

COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
ruby    21309 user   11u  IPv4  93186      0t0  TCP *:3000 (LISTEN)

and then kill your ruby process by using

kill -9 <PID>

start your server again by rails s

Hope it helps!

like image 148
LHH Avatar answered Feb 23 '23 00:02

LHH