Reputation: 201
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.
Upvotes: 20
Views: 15141
Reputation: 3387
...and have configured your app as myapp
, you can't access it as myapp.dev
from the guest machine, but you can use the "magic" xip.io
domain. Just access http://myapp.10.0.2.2.xip.io
and it should work!
Upvotes: 0
Reputation: 401
Using NAT:
http://127.0.0.1:3000
Upvotes: 40
Reputation: 12550
If you're running rails in development mode, it comes with webrick
by default which has access restricted just to localhost.
You could use something like thin
in dev, which allows access from another machines.
Upvotes: 1
Reputation: 2220
The answer is yes there is a simple way to do it. I am using VirtualBox on OS X Mountain Lion, but I suspect it will work the same for Ubuntu.
192.168.xxx.xxx:3000
ipconfig /all
on your virtual machine in the command prompt (use windows search / find (windows+f) and search for 'cmd') Look for Default Gateway
and use that IP. In my case it is 10.0.2.2
so 10.0.2.2:3000
worksUpvotes: 17
Reputation: 4109
Start Rails server remotely and then just connect to it:
http://virtualboxhost:3000
If it doesn't work:
Upvotes: 0
Reputation: 30773
You need the local IP of Ubuntu. To get this type ifconfig
in the terminal.
I've had success using NAT with virtualbox, after you get the machine's ip, type it with the 3000 port from the VM and you should be able to access it.
Upvotes: 0
Reputation: 309
Instead of localhost you should have typed the IP of the host machine. With bridged mode the vm and your host machine have a different IP in your local network.
Upvotes: 6