What to do if you get an "A server is already running." Error when you try to start the rails server

When I try to start rails server, I get the following error and may not be able to start it.

$ rails s -b 0.0.0.0
=> Booting Puma
=> Rails 5.2.4.2 application starting in development 
=> Run `rails server -h` for more startup options
A server is already running. Check /Directory path/tmp/pids/server.pid.
Exiting

This is an error that occurs because the server is already running. Here's what to do in this case.

Kill the PID of server.pid

All you have to do is kill the PID number in /tmp/pids/server.pid. Even if I manually delete the server.pid file, the server is still running, so Execute the following command to find and kill the process running on number 3000.

$ lsof -i:3000
COMMAND  PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
ruby2.5 3033 vagrant   16u  IPv4  27499      0t0  TCP *:3000 (LISTEN)

Kill the PID number found by the above command with the following command.

$ kill -9 3033

This will shut down the server and start it fine.

Reference article

https://qiita.com/motty93/items/d22c1eb8f5128f8cd7f8

Recommended Posts

What to do if you get an "A server is already running." Error when you try to start the rails server
What to do if you get an error saying "Could not find a JavaScript runtime." When starting rails server
What to do if you get Application with name appName is already registered. When you try to start GlassFish
[Rails] What to do if you can't get an error message with the errors method
What to do if you get an error during rails db: reset
What to do if you get an error when you hit Heroku logs
What to do if you get an error saying "Please enter a valid value" when getting with Rails datetime_field
What to do if the Rails server can't start
[Rails] What to do if you get an error saying "Could not find a JavaScript runtime." When executing the rails s command on Catalina
What to do if you get a SQLite3 :: BusyException: database is locked error
What to do if you get the error Couldn't find Item without an ID
What to do if you get a port error when docker-compose up on Mac
What to do about "A server is already running ..." that happened without turning off the rails server in the terminal
What to do if you get a gcc error in Docker
Remedy for "A server is already running." Error when running rails s
I get a Ruby version error when I try to start Rails.
What to do if you get a DISPLAY error in gym.render ()
What to do if you get a "Cannot Pull Container Error" when starting ECS ​​Fargate
What to do if you get a "302" error in your controller unit test code in Rails
What to do if you get an error in Basic authentication during Rails test code
[Solution] What to do if you get a Docker error'ERROR: Cannot connect to the Docker daemon at unix: ///var/run/docker.sock. Is the docker daemon running?'
What to do if you get a "Mysql2 :: Error: Operand should contain 1 column (s)" error in Rails
What to do if you get a JNI shared library error when trying to build in Eclipse
<Dot installation> What to do if you cannot proceed due to an error when building a development environment for Rails learning.
[Grails] Error occurred running What to do when the Grails CLI does not start
What to do if you get an error on heroku rake db: migrate
What to do if Operation not permitted is displayed when you execute a command in the terminal
What to do if you get a wrong number of arguments error in binding.pry
What to do if you get a java.io.IOException in GlassFish
What to do if you can't get the text of an element in Selenium
What to do when you launch an application with rails
What to do if you get a NoClassDefFoundError when trying to run eclipse on Java9
What to do if you can't use the rails command
What to do if you get ActiveRecord :: StatementInvalid: Mysql2 :: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near when you try to reset Heroku
[Rails Tutorial Chapter 2] What to do when you make a mistake in the column name
[Rails] What to do when the view collapses when a message is displayed with the errors method
What to do if Cloud9 is full in the Rails tutorial
[Rails] What to do if you can't get parameters with form_with
What to do if you go offline due to SSL certificate error when running Jenkins on Mac
[Programming beginner] What to do when rails s becomes an error in the local development environment
If you get a "Quantum Renderer: no suitable pipeline found" error when running the jar file
What to do if you get an [An HTTP request took too long to complete.] Error in Docker.
What to do if the app is not created with the latest Rails version installed when rails new
What to do if you get a groovy warning in Thymeleaf Layout
[Android Studio] What to try when you get into error spitting hell
What to do if an error occurs when nokogiri enters when bundle install
What to do if you get a MiniMagick vulnerability alert on GitHub
What to do if the server tomcat dies
What to do if you get an error with bundle install by entering gem'bcrypt' in your Gemfile
What to do if you should have installed Rails but an error occurs with rails -v (for beginners)
What to do if the image posted by refile disappears after setting a 404 error page in Rails
What to do if zip dies if there is a pom when making an executable jar with gradle
What to do if you get the error Too long with no output (exceeded 10m0s) on CircleCI
[Rails / Docker] What to do if access is denied by the browser (localhost: 3000) after adding a gem
What to do if you get `rescue in block in modules_for_hoge': Missing hoge file hoge / hoge_hoge.rb (AbstractController :: Helpers :: MissingHogeError) in rails s even though the file is in the specified error location.
What to do if you get the error message "Don't try to install it manually: your package manager does it automatically. However, a different version of webpack was detected higher up in the tree:" when you do "npm start" Law
What to do if you get To install the missing version, run `gem install bundler: 2.1.4`
Androd: What to do about "The Realm is already in a write transaction in"
What to do when is invalid because it does not start with a'-'
What to do if the rails server doesn't run out on AWS cloud9
What to do if ffi installation fails when launching an application in Rails