Accessing Rails Server From VirtualBox

ruby-on-rails, virtualbox

Solution

Using NAT:

- Go to VirtualBox... Settings -> Network -> Port Fowarding

- Enter 3000 for Host Port

- Enter 3000 for Guest Port

- Go to your VirtualBox guest machine.

- In the terminal run ifconfig, use the inet addr for eth0. In my case it is 10.0.2.15

- When you run the rails server, in the VirtualBox guest machine, use the following command: $ rails server -b 10.0.2.15 You want to bind to that address.

- On your Host System, go to the browser and visit `http://127.0.0.1:3000`

Problem

I am currently running Rails 3.2.3 server on a laptop running Ubuntu 12.04 and would like to access it via VirtualBox (ver 4.1.16) from a WinXP (SP3) VM, which is also running on the laptop. Tried using bridged networking instead of NAT but end up with a refused connection in Firefox (ver 13). Firefox displays an error page which includes the following: Unable to connect. Firefox can't establish a connection to the server at localhost:3000. Is there a straightforward way to access the Rails server from VirtualBox remotely? Not sure if Vagrant will resolve the issue since it is designed to work the other way around (from the host OS to the VM). Would be good to access the Rails server remotely as it means testing can be easily done with Internet Explorer (using ver 8) on a single PC on demand.

Original source

Related problems