0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

rails sがうまくいかない時の対応

Last updated at Posted at 2019-12-14

rails sでサーバーを立ち上げた後、Ctrl + Cで終了せずにターミナルを終了しちゃったりすると、次回起動時に以下のようなエラーが発生します。

$ rails s
=> Booting Puma
=> Rails 5.0.4 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
A server is already running. Check プロジェクト名/tmp/pids/server.pid.
Exiting

対処方法

$ kill $(cat tmp/pids/puma.pid)

or

$ lsof -ni tcp:3000 #or lsof -i:3000
COMMAND   PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ruby    77464 d0ne1s   20u  IPv4 0xe8bde147dfa7a793      0t0  TCP 127.0.0.1:hbci (LISTEN)
ruby    77464 d0ne1s   22u  IPv6 0xe8bde147d9f527d3      0t0  TCP [::1]:hbci (LISTEN)

$ kill -9 77464

lsof:オープンしているファイルを一覧表示するコマンド
-n:IPアドレスを表示する(名前解決しない)
-i:ポート番号やプロトコルを指定する

kill:プロセスを終了する
-9:強制終了

参考

Rails sのプロセスが切れない時
【 lsof 】コマンド――オープンしているファイルを一覧表示する

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?