58
56

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 5 years have passed since last update.

developmentでWEBrick起動のRailsはbindオプションでanyアクセスを受け付けるようになる

Last updated at Posted at 2014-11-03

VirtualBox で起動した guest OS の Rails アプリにアクセスしようとしてハマったのですが development のデフォルト設定では localhost からのアクセスしか受け付けません(この場合もちろん guest OS にとっての localhost)。WEBRick だと bind オプションで binding IP Address を指定して host OS からアクセスできるようになります。

bundle exec rails s --bind=0.0.0.0

host only network 設定してある guest OS の Rails アプリに host OS からアクセスできなくて iptables を無効にしてるのになんで?と思いしばらく格闘していたのですが…一旦あきらめて JavaScript で遊んでて node で http-server を立ち上げてダメ元でアクセスしたらすんなりいけたもので気が付きました…なるほどこういうときは netstat -an で Local Address を調べるとよいのか。

指定なし
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 127.0.0.1:3000              0.0.0.0:*                   LISTEN
--bind=0.0.0.0
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 0.0.0.0:3000                0.0.0.0:*                   LISTEN

参考

58
56
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
58
56

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?