LoginSignup
1
1

More than 5 years have passed since last update.

VagrantでRails4.2を動かす時には、listenするAddressを指定しないとダメ

Last updated at Posted at 2016-08-24

vagrantでサーバーを立てて、自分のローカルマシンからRailsにアクセスする時の動作が、Rails4.2系から
変更されている。

Rails4.2系で普通に動かした場合には、自分のローカルマシンからはアクセスできない。

rails s

スクリーンショット 2016-08-24 17.45.01.png

Local Addressが127.0.0.1に指定されている。
Local Addressが指定されている場合は、接続先アドレスがそのアドレスの接続しか受け付けないようになっています。

Rails4.1系で普通に動かした場合には、自分のローカルマシンからはアクセスできる。

スクリーンショット 2016-08-24 17.43.51.png

Local Addressが0.0.0.0に指定されている。

では、Rails4.2系でローカルからアクセスできるようにするには、どうしたらいいのか?

RailsがBindするIPを変更すればいい

rails s -b 0.0.0.0

スクリーンショット 2016-08-24 17.49.09.png

Local Addressが0.0.0.0に変更されました。

1
1
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
1
1