0

Here are two GitHub repositories:

Each one basically* contains the default boilerplate program that gets generated when you type "rails new APP_NAME" into a terminal.

I am deploying them identically to a remote server (specifically an EC2 instance in AWS).

  • For the first one, the "rails server" on port 3000 is accessible remotely.

  • For the second one, the "rails server" on port 3000 is NOT accessible remotely.

Would anyone be able to shed some light as to why this is the case?

To provide some background:

The first was generated in May 2014, the second was generated in March 2015.

*The first I might've tinkered with slightly, but I cannot remember what I changed (this is the driver of my question). The second is unmodified.

Maarx
  • 633
  • 1
  • 7
  • 18

1 Answers1

4

You may notice that your earlier project (rails 4.1.1) prints something like this at bootup:

=> Rails 4.1.1 application starting in development on http://0.0.0.0:3000

Whereas, the later project (rails 4.2.0) prints something like:

=> Rails 4.2.0 application starting in development on http://localhost:3000

The difference here is that the first project is listening on 0.0.0.0 (any ip) and the second is listening on localhost (127.0.0.1), which is only accessible from localhost.

You can bind your rails server to any ip with the -b option:

rails server -b 0.0.0.0

See http://guides.rubyonrails.org/4_2_release_notes.html#default-host-for-rails-server for more information on the change and How to change the default binding ip of Rails 4.2 development server? for how to change the default.

Community
  • 1
  • 1
Amiel Martin
  • 4,636
  • 1
  • 29
  • 28
  • Thanks! I knew that "rails server -b 0.0.0.0" would override the situation, but I knew I wasn't (yet) using this in either case, so I couldn't understand the difference within the application codebase. The missing bit of information for me was that the default behavior changed in Rails 4.2. Thanks! Bonus points for the link to the documentation! :) – Maarx Mar 11 '15 at 01:36