Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having problems connecting to my local virtual machine if I'm off the internet. When I'm properly connected to the internet, I have no problem also connecting to my local server.


  • Host: MacBook Pro, OSX Snow Leopard
  • Guest: VirtualBox, Fedora with Apache Httpd webserver

Use case

I am developing web applications, which are served by my local virtual webserver. I browse them from the host browser.

When AirPort is correctly connected to a wifi, I can also connect to the local webserver, but as soon as I don't have wifi connection, or if I turn off AirPort manually, I also lose the connection to the local webserver. This is a problem since I would like to be able to take my laptop anywhere and be able to do development work.

The solution?

Should I change the network setting for the vm in VirtualBox, or is it a OSX setting related to AirPort or the ethernet card that can fix this?

If you need more details about my configuration, let me know and I will amend.

Thanks, Jakob

share|improve this question
In the end I found a solution myself, see my answer below. If you have another/better solution, or can explain why this works or won't work in some situations, please share! – jgivoni Jul 25 '12 at 21:57

You will need to tell Virtualbox to not use NAT Mode, which depends on ONE certain host-only connection to be activated. Instead, you can use Host Only, which will not care if there is Internet or not. Option two is to use Bridged mode, but through a host only adapter (more work).

In the event this happens often, I would just add a second NIC to the VM, that is Host Only. Use that IP address, even if on the Internet, when you want to connect to the Virtual Machine. It will only be visible to your host anyways, and isn't reliant on anything else.

With NAT mode, you will NEED to be connected to a network with your host in order to use this mode. Same thing with Bridged, except Bridged makes the VM more like a physical machine by having it's own IP address on the network you're connected to

share|improve this answer
I have both a NAT adapter and a Bridged adapter, and now I tried to add a Host-only adapter. It didn't help. Are you saying I should only keep the Host-only, and remove the others? – jgivoni Jul 25 '12 at 20:46
I would recommend ADDING or replacing NAT with Host Only. When you do, you do not need Internet access at all for the VM to connect, or to connect to the VM – Canadian Luke Jul 25 '12 at 20:50
I tried removing the NAT adapter and restarted the vm. The ip address to the vm is the same. I still cannot connect, but instead of "Can't connect" / "No route to host" I now get put on hold: "Server is taking too long" / "Operation timed out". This even happens while AirPort is on and connected, so it's kind of a step backwards ;-) Thanks for the help so far, hope you have a few more ideas up your sleeve! – jgivoni Jul 25 '12 at 21:00
Are you using a static IP on the VM? If so, this won't work – Canadian Luke Jul 25 '12 at 21:05
I'm not sure how the ip is assigned, but I think it's VirtualBox managing it, and it always stays the same. Why should it not be static? – jgivoni Jul 25 '12 at 21:14
up vote 0 down vote accepted

Create a local wifi network by selecting

Create Network

from the AirPort dropdown menu (the wifi icon).

In the dialog "Create a Computer-to-Computer network." just go for the defaults.

This will ensure your AirPort adapter doesn't deactivate.

Then configure it with this command in the terminal:

sudo ifconfig en1 netmask up

This will reenable its routing capabilities.

I don't know if the ip addresses might be different in your case, but I think the important thing is the netmask, making sure the ip addresses of host and guest are in the same subnet.

I solved my problem like this, hope others can use this answer.

share|improve this answer
How do you know that the correct IP address is Surely this varies by network? – geoidesic Feb 9 '15 at 12:00
I'm sure it may vary. I guess you could find a way to get the correct IP address before trying this. – jgivoni Feb 10 '15 at 10:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .