Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bind rails app on the IP provided by the host with 3000 port

I am running the rails app on VPS server provided by my host.

I need to run the same local app to the IP provided by them.

For eg myip:3000

Is it possible to do this, the IP provided by the host is a public/global IP.

How can I do this? Sorry for the dumb question.

like image 362
Suraj Avatar asked Dec 29 '16 12:12

Suraj


1 Answers

After the release of Rails 4.2 the you cannot access the development mode rails server from another computer/virtual machine (remote access). So you need to bind the server to the ip. You can do it by:

rails s -b 0.0.0.0

0.0.0.0 (means listen on all interfaces)

If you want to do it permanently you can do it by modifying the config/boot.rb like this:

require 'rubygems'  
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

Source: https://fullstacknotes.com/make-rails-4-2-listen-to-all-interface/

like image 191
Deepesh Avatar answered Oct 26 '22 23:10

Deepesh