Quickly solve A server is already running (rails s process does not break)

** What to do if you get the following when you try to start the server ** We have summarized several types! It can be solved by either (should).

❯ rails s
=> Booting Puma
=> Rails 5.0.7.2 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
A server is already running.Check project name/tmp/pids/server.pid.
Exiting

There are many types, so if something goes wrong, we recommend trying them in order.

Check first

Occasionally, there are people who are trying to start the server with a terminal on a text editor such as Mac standard terminal with server start state &` VS Code. First of all, let's check ** if the server is already running in another terminal **!

Pattern ①

Delete the rails process

$ rails s
=> Booting Puma
=> Rails 5.0.7.2 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
A server is already running.Check project name/tmp/pids/server.pid.
Exiting

$ ps aux | grep rails
user   28321 s001  S+     0:00.00 grep rails

$ kill -9 28321

$ rails s
→ Solution

Pattern ②

Delete process with port number 3000

$ lsof -wni tcp:3000
COMMAND   PID  USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ruby    28295  user   21u  IPv4 0x77d8a30cabb79cc9      0t0  TCP 127.0.0.1:hbci (LISTEN)
ruby    28295  user   22u  IPv6 0x77d8a30cac93f9f9      0t0  TCP [::1]:hbci (LISTEN)

#Copy the PID of the line that says "ruby" in "COMMAND" and stop the process(This time 28295)
$ kill -9 28295

$ rails s
→ Solution

Pattern ③

Delete the ID used when starting the server

$ rm /tmp/pids/server.pid

$ rails s
→ Solution

The location of this file is in [app name] /tmp/pids/server.pid, so specify the path and delete it. Originally, this file is deleted when the server is shut down, but it seems that there is a possibility that it remains and an error occurs.

Summary

The frequently-used kill -9 ○○ is one of the Linux commands to terminate the process. Personally, I feel that ** pattern ② ** can often end the process smoothly.

If you get stuck when you start the server, it will wither, so please solve it quickly!

Recommended Posts

Quickly solve A server is already running (rails s process does not break)
Remedy for "A server is already running." Error when running rails s
A server is already running. Check / [WORKDIR] /tmp/pids/server.pid. Solution
When the server does not start with rails s
MySQL is not running stably ... Rails app is not running.
What to do if you get an "A server is already running." Error when you try to start the rails server
What to do about "A server is already running ..." that happened without turning off the rails server in the terminal
Many error lines ... Rails server does not start 2. "Autodetect': Could not find a JavaScript runtime."