E
E
eldar_web2015-04-03 10:55:08
Ruby on Rails
eldar_web, 2015-04-03 10:55:08

rails. Ubuntu. Why in Windows in the browser it is impossible to display a site that is running in a virtual machine (ubuntu) via localhost:3000?

In the rails virtual machine, the project (rails s) is launched, but in Windows it does not display anything.
What could be the problem?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
O
OnYourLips, 2015-04-03
@eldar_web

Actual rails only bind port 3000 to localhost.
Therefore, we fix:
config/boot.rb

ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'rails/commands/server'

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

B
bukovki, 2015-04-03
@bukovki

rails s -b 0.0.0.0

E
Eugene Burmakin, 2015-04-03
@Freika

Because you need to forward ports from the virtual machine to the local host machine. In Vagrant, this is done with one line in the virtual machine config.

D
Daniel254, 2015-04-03
@Daniel254

add a setting to your vagrant config (or change an existing one):

config.vm.network "forwarded_port", guest: 3000, guest_ip: "localhost", host: 3000, host_ip: "localhost"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question