When I stopped the server while doing something, when I tried to start the server again, the following error occurred.
`bind': Address already in use - bind(2) for 127.0.0.1:3000 (Errno::EADDRINUSE)
Error that port 3000 is already in use. There are two solutions
If the 3000th boat is used, you can start the server using another port.
#Start up on a port other than 3000
rails s -p 8000
Check the currently running ruby process
$ ps -ax | grep ruby
If there is a running process, it will be displayed as follows.
6462 ttys011 0:12.64 /Users/*****/.rbenv/versions/2.5.3/bin/ruby bin/rails server
8380 ttys011 0:00.00 grep ruby
Kill the running rails process.
$ kill 6462
Check if the process has been killed
$ ps -ax | grep ruby
6462 ttys011 0:12.64 /Users/*****/.rbenv/versions/2.5.3/bin/ruby bin/rails server
8380 ttys011 0:00.00 grep ruby
It seems that it is not cut, so add an option to the kill command and forcibly kill it
# "-9"Is a kill option
$ kill -9 6462
#Reconfirm process
$ ps -ax | grep ruby
8405 ttys011 0:00.00 grep ruby
Now that the rails process is dead, the rails server should be up and running.
-Solution for error "Address already in use --bind (2) for" 0.0.0.0 "port 3000" at rails s [Beginner]
-[Kill] Command to kill process on Linux
Recommended Posts