BrightBlue
BrightBlue

Reputation: 417

Rails application not visible to local network

For the first time since upgrading to OSX Yosemite, I need to view an app running on my machine from another machine on the same network. Previously, this was as simple as finding my internal IP address and using that with port 3000, eg. http://192.168.0.111:3000.

However, I am now finding that with Yosemite this doesn't work. The application is definitely running and is available via localhost:3000 but not via my internal IP.

I have run the network utility port scanner and it shows that localhost exposes port 3000 but my IP doesn't. Other machines on the network that have yet to upgrade (10.7.5 and 10.9.5) are not having this issue.

Any help would be greatly appreciated.

Edit: According to the security and privacy pane of the system preferences, the Yosemite firewall is currently off - so that isn't causing the problem.

Upvotes: 25

Views: 6207

Answers (1)

Matt Brictson
Matt Brictson

Reputation: 11102

By default, rails server will only accept connections from localhost. You can check this by looking at the console output:

Listening on localhost:3000, CTRL+C to stop

To listen on all addresses, which will allow you to connect from other machines on the local network, you must explicitly bind to a more permissive address. Try this:

rails server --binding=0.0.0.0

You should now see:

Listening on 0.0.0.0:3000, CTRL+C to stop

Now you can connect to your Rails app from elsewhere on your local network, by browsing to e.g. http://192.168.0.111:3000.

Upvotes: 50

Related Questions