ROR + A server is already running. Check …/tmp/pids/server.pid. Exiting

后端 未结 14 1861
渐次进展
渐次进展 2020-12-22 23:55

In my Rails Project, I am trying to run two different servers at different port. But it fails by giving this error at console.

C:\\Rails>rails s
=> Boo         


        
相关标签:
14条回答
  • 2020-12-23 00:15

    Try to change the number in the pid file to another and save it.

    0 讨论(0)
  • 2020-12-23 00:24
    ps aux | grep rails
               or 
    bundle exec rails s -p 3001 -P tmp/pids/server2.pid
    
    0 讨论(0)
  • 2020-12-23 00:25

    Step 1: remove .pid

    C:/Rails/tmp/pids/server.pid.Exiting
    
    # IN linux/unix shell
    $ rm -rf <path to file>
    

    Sometime this doesn't solve the problem, then you have to kill the process running by localhost, for such cases, follow STEP 2

    STEP 2: List the process for localhost and kill it

    # For Linux/Unix shell
    
    $ lsof -wni tcp:3000
    
    # output
    COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
    ruby    5946 rails   11u  IPv4  79073      0t0  TCP *:3000 (LISTEN)
    ruby    5946 rails   12u  IPv4 103786      0t0  TCP 127.0.0.1:3000->127.0.0.1:53612 (ESTABLISHED)
    
    # Kill the running process
    $ kill -9 5946
    

    run your server again

    rails server
    
    0 讨论(0)
  • 2020-12-23 00:28

    I find myself coming back to this webpage a lot to find the lsof -wni tcp:3000 command so I've found this method to be easier.

    If you get this message:

    A server is already running. Check /Users/username/project/tmp/pids/server.pid.
    Exiting
    

    And if you're running on a unix system (mac or linux) you can run these commands:

    $ cat /Users/username/project/tmp/pids/server.pid
    
    # output
    
    71030
    
    # Kill the process
    
    $ kill -9 71030
    

    Then run your server again!

    0 讨论(0)
  • 2020-12-23 00:29

    Remove that file: C:/Rails/tmp/pids/server.pid

    0 讨论(0)
  • 2020-12-23 00:31

    You can see the PID for each proccess(the first column) :

    ps vax | grep rails
    // OR:  ps auxw | grep rails
    
    5236 pts/1    Sl+    1:46   2   0.2 /usr/bin/ruby1.9.1 script/rails s -p 3001
    5298 pts/2    Sl+    0:12   2   0.7 /usr/bin/ruby1.9.1 script/rails s -p 3003
    7356 pts/5    Sl+    0:09   2   0.9 /usr/bin/ruby1.9.1 script/rails s -p 3002
    7846 pts/3    Sl+    0:19   2   1.7 /usr/bin/ruby1.9.1 script/rails s
    

    Then kill the server:

    kill -9 <pid>
    

    To kill all running apps with "rails" in the name:

    killall -9 rails
    
    0 讨论(0)
提交回复
热议问题