** 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.
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 **!
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
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
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.
Server.pid
is created or deleted without permission when the server is started or stopped, so you do not usually have to worry about it.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!