LoginSignup
0
0

More than 1 year has passed since last update.

【Rails】rails sでエラーが発生する `initialize': Address already in use - bind(2) for "127.0.0.1" port 3000 (Errno::EADDRINUSE)

Posted at

状況

rails sでサーバーを立ち上げようとしたら以下のエラーが発生しました。

$ bin/rails s
=> Booting Puma
=> Rails 6.1.7.3 application starting in development 
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 5.6.5 (ruby 3.2.1-p31) ("Birdie's Version")
*  Min threads: 5
*  Max threads: 5
*  Environment: development
*          PID: 8832
Exiting
/Users/name/app_name/vendor/bundle/ruby/3.2.0/gems/puma-5.6.5/lib/puma/binder.rb:341:in `initialize': Address already in use - bind(2) for "127.0.0.1" port 3000 (Errno::EADDRINUSE)

しかしpsコマンドで、実行されているプロセスを確認してもサーバーは表示されませんでした。
また、tmp/pids/server.pidの値を削除してみても直らず。

解決法

以下のコマンドでport 3000を使用しているプロセスを表示します。

$ lsof -i :3000
ruby    32184 name   13u  IPv4 0xbceeb2e3b353     0t0  TCP localhost:hbci (LISTEN)
ruby    32184 name   15u  IPv6 0xbceeb2e875f5      0t0  TCP localhost:hbci (LISTEN)

表示されたプロセスをkillします

$ kill 32184

これでサーバーを再度起動させることができました。

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