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.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With