I've installed Rails 4.2 on a Ubuntu 14.04 VM to act as a development environment. When I start the rails server with rails s
the server says it starts and is listening for connections on http://localhost:3000
If I try to access <IP>:3000
, no page is displayed and nothing hits the logs of the rails server. If I execute curl localhost:3000
from within the machine, I get the html of my home page.
If I execute rails s -b 0.0.0.0
, I can access the server by its IP address.
On my MacBook Pro, running rails s
(listening to localhost
) allows me to access the rails app via localhost:3000
or <IP>:3000
.
http://edgeguides.rubyonrails.org/4_2_release_notes.html#default-host-for-rails-server
Rails 4.2 release notes say, that now default host for rails server is localhost.
So if you want to access app from another machine, use
rails server -b 0.0.0.0
Probably your Macbook Pro uses older Rails version, with old behavior
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.