How to change the default binding ip of Rails 4.2 development server?

I'm having the same issue here and I found today a better solution. Just append this code to your config/boot.rb and it should work with vagrant.

require 'rails/commands/server'
module Rails
  class Server
    def default_options
      super.merge(Host:  '0.0.0.0', Port: 3000)
    end
  end
end

ps: Its based on: this answer


You can use foreman to run a Procfile with your custom commands:

# Procfile in Rails application root
web:     bundle exec rails s -b 0.0.0.0

Now start your Rails application with:

foreman start

The good thing about foreman is that you can add other applications to the Procfile (like sidekiq, mailcatcher).

The bad thing about foreman is that you have to train your team to run foreman start instead of rails s.


Met the same problem. Found the blog Make Rails 4.2 server listens to all interfaces.

Add the following to config/boot.rb

require 'rails/commands/server'

module Rails
  class Server
    alias :default_options_bk :default_options
    def default_options
      default_options_bk.merge!(Host: '0.0.0.0')
    end
  end
end