Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails application not visible to local network

Tags:

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.

like image 703
BrightBlue Avatar asked Mar 18 '15 21:03

BrightBlue


People also ask

How do I run a Rails application in a staging environment?

That environment is no different than the default ones, start a server with bin/rails server -e staging, a console with bin/rails console -e staging, Rails.env.staging? works, etc. By default Rails expects that your application is running at the root (e.g. / ). This section explains how to run your application inside a directory.

What are the different environments in rails config?

The config/database.yml file contains sections for three different environments in which Rails can run by default: The development environment is used on your development/local computer as you interact manually with the application. The test environment is used when running automated tests.

Where can I find discussion about Ruby on rails documentation?

And last but not least, any kind of discussion regarding Ruby on Rails documentation is very welcome on the rubyonrails-docs mailing list .

How to run code before rails is loaded?

In the rare event that your application needs to run some code before Rails itself is loaded, put it above the call to require "rails/all" in config/application.rb. In general, the work of configuring Rails means configuring the components of Rails, as well as configuring Rails itself.


1 Answers

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.

like image 169
Matt Brictson Avatar answered Sep 28 '22 03:09

Matt Brictson