Rails Server on Developing Machine Won't Stop (Windows 10 Linux Subsystem Ubuntu Disco Dingo)
When developing in Ruby on Rails and Rails Server does not stop or gets stuck in a loop, a few commands will help you stop the server (On Linux Machine type: pkill -9 -f ruby) remember the last argument should be the name of the process Rails Server is running on.
However, after restarting the Rails Server (Rails s -b 0.0.0.0) you might notice that the web application you are developing is not rendering properly. This is because the Rails Process did not get Collected by the Operating System Garbage Collection, chances are that components of the Rails Server are still running/active.
The way you resolve this issue is by starting a Rails Server on a different port by inputting this command: rails s -p 3001
- [NB] rails start # To start the server in a development environment
- rails start production # To start the server in the production environment
- rails stop # To stop the server
- rails stop -9 # To stop the server sending -9 kill signal
- rails restart # To restart the server in the development environment
- rails restart production # To restart the server in the production environment
- rails whatever # Will send the call to original rails command
- pkill -9 -f puma # Will kill puma process
If starting the server on a different port does not help or the same problem happens again, then try to clean up the hung-up processes by inputting the following commands:
- pkill -9 -f ruby (this will force terminate ruby process)
- pkill -9 -f rails (this will force terminate rails process if you have any active)