A server is already running. Check …/tmp/pids/server.pid. Exiting - rails

前端 未结 19 1440
礼貌的吻别
礼貌的吻别 2021-01-29 20:35
..$ rails s
=> Booting WEBrick
=> Rails 4.0.4 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=>         


        
19条回答
  •  后悔当初
    2021-01-29 20:48

    SOLVING

    Address already in use — bind(2)” 500 error in Ruby on Rails

    Recently I tried running a Rails app on a production server. Not only did it not work, but it broke my localhost:3000 development server as well. Localhost would only load a blank white page or a 500 error.

    To solve this, I used two quick commands. If these don’t return a result, you may need to look elsewhere for a solution, but this is a good quick fix.

    lsof -wni tcp:3000

    
    ruby    52179 rachelchervin   50u  IPv6 0x...7aa3      0t0  TCP [::1]:hbci (LISTEN)
    ruby    52179 rachelchervin   51u  IPv4 0x...c7bb      0t0  TCP 127.0.0.1:hbci (LISTEN)
    ruby    52180 rachelchervin   50u  IPv6 0x...7aa3      0t0  TCP [::1]:hbci (LISTEN)
    ruby    52180 rachelchervin   51u  IPv4 0x...c7bb      0t0  TCP 127.0.0.1:hbci (LISTEN)
    
    

    This command shows all of my currently running processes and their PIDs (process IDs) on the 3000 port. Because there are existing running processes that did not close correctly, my new :3000 server can’t start, hence the 500 error.

    kill 52179

    kill 52180

    rails s

    I used the Linux kill command to manually stop the offending processes. If you have more than 4, simply use kill on any PIDs until the first command comes back blank. Then, try restarting your localhost:3000 server again. This will not damage your computer! It simply kills existing ruby processes on your localhost port. A new server will start these processes all over again. Good luck!

提交回复
热议问题