Rails 4.2开发服务器无法访问Ubuntu 14.04

Tyl*_*itt 2 ubuntu networking ruby-on-rails ubuntu-14.04

我在Ubuntu 14.04 VM上安装了Rails 4.2作为开发环境.当我启动带rails s服务器的rails服务器时,它说它启动并正在监听连接http://localhost:3000

如果我尝试访问<IP>:3000,则不会显示任何页面,也不会触及rails服务器的日志.如果我curl localhost:3000在机器内执行,我会获得主页的html.

如果我执行rails s -b 0.0.0.0,我可以通过其IP地址访问服务器.

在我的MacBook Pro上,运行rails s(收听localhost)允许我通过localhost:3000或访问rails应用程序<IP>:3000.

  • Ubuntu 14.04.1
  • Rails 4.2

Sta*_*hin 11

http://edgeguides.rubyonrails.org/4_2_release_notes.html#default-host-for-rails-server

Rails 4.2发行说明说,现在rails服务器的默认主机是localhost.

因此,如果您想从其他计算机访问应用程序,请使用

rails server -b 0.0.0.0
Run Code Online (Sandbox Code Playgroud)

可能你的Macbook Pro使用旧的Rails版本,旧的行为