× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Stop rails server from the command line

<p>Sometimes, you get an error while trying to run your rails server saying that, <em>the server is already running </em>and you are not sure where and how the server is running and how to stop that rails server so that you can run the server for the current project. You tried closing the terminal and also tried pressing <strong>Ctrl+c</strong> but no luck!</p> <p>In such cases, you can do these:</p> <p>In your terminal to find out the <code>PID</code> of the process (assuming your rails server is running on port 3000):</p> <pre><code><span style="color:rgb(0, 0, 0)">$ lsof </span><span style="color:rgb(0, 0, 0)">-</span><span style="color:rgb(0, 0, 0)">wni tcp</span><span style="color:rgb(0, 0, 0)">:</span><span style="color:rgb(128, 0, 0)">3000</span></code></pre> <p>Then, kill the process:</p> <pre><code><span style="color:rgb(0, 0, 0)">$ kill </span><span style="color:rgb(0, 0, 0)">-</span><span style="color:rgb(128, 0, 0)">9</span><span style="color:rgb(0, 0, 0)"> PID</span></code> </pre> <p>Another way of doing it: You can also use the following command to kill all running apps with <code>rails</code> in the name:</p> <pre><code><span style="color:rgb(0, 0, 0)">killall </span><span style="color:rgb(0, 0, 0)">-</span><span style="color:rgb(128, 0, 0)">9</span><span style="color:rgb(0, 0, 0)"> rails</span></code> </pre> <h3><code><span style="color:rgb(0, 0, 0)">That's it. Now, you should be able to run your rails server for the desired project.</span></code></h3> <p><code><span style="color:rgb(0, 0, 0)">P.S. This is originally posted as one of my <a href="http://stackoverflow.com/a/33427854/981183">StackOverflow answers.</a></span></code></p>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus