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

Here's my setup:

  • I have a local server running on my machine (Mac OS, Snow Leopard). I can access it via my browser by doing


  • I have a virtual machine using Virtual Box running a windows XP. If I try to access using localhost:3000, it fails. Same thing if I use the ip of the Mac machine.

  • The virtual machine has access to the internet.

How can I access my local server in my virtual machine?

share|improve this question
if you try to access "localhost" on the virtual machine, it tries to connect to itself, instead of to the macosx server. I think the answers up to now missed that point – brandstaetter Nov 24 '09 at 13:46
I know this is and old thread, but here is the answer… – deiga Aug 23 '12 at 4:57
@deiga: Thanks, that link had the answer. – Igor Rodriguez Jun 2 '13 at 14:13

How do you have your network setup in the Virtual Machine?

It sounds like you might have it setup using NAT. In this situation, if your host machine(Mac) has a non-routable(private) IP address such as 192.168.x.x, you will not be able to reach the host from within the virtual machine. The reason you cannot reach the host from the guest is that you are essentially setting up 2 separate private networks. Your Mac computer is on one (192.168.x.x) and your VM on another (perhaps 10.x.x.x) and you essentially have a router between them. Since routers will not route private IPs, the two networks can never communicate with each directly.

If you want your host and guest machines to be able to communicate, you will probably want to setup your VirtualBox network adapter to be attached to the "Bridged Adapter." This will share your internet connection with the virtual machine and allow your guest machine to talk to the host. In this situation you are essentially adding your VM as an additional node to the local network your Mac is already on.

share|improve this answer
Under "Bridged Adapter", both the host and the guest will have IP addresses under the same subnet (i.e. 192.168.x.x), correct? – kdbanman May 13 '15 at 19:09
@kdbanman, correct (assuming the host network is using DHCP), the VM will show up as another machine on the host network. – heavyd May 13 '15 at 19:12
That seems like a much more natural way to set up a VM. Why would one use a separate private network with NAT? Security? – kdbanman May 13 '15 at 19:16
Yes, NAT provides isolation. Also, some networks will not allow just any host to connect, so using NAT can allow the VM to access network resources through the hosts' interface. Its also used as the default for this reason, its a less error prone setup, but I agree I prefer bridged in most situations. – heavyd May 13 '15 at 19:21

Depending on the network settings of your vm, you'll probably need to add an additional IP to the Host OS that's on the same subnet as your vm so they can communicate. Your vm probably has a 192.168.x.x address, so add a similar address to the Mac machine:

example, if the vm has and subnet mask, you can do this to your host:

ifconfig eth0:0 netmask up

you'll probably need to restart the adapter as well.

share|improve this answer

I have had the same exact problem, only I was using Windows 7 as a guest.

What I did was Start -> Run -> cmd to bring up the command line.

ipconfig to bring up connection details. Look for the address that looks like 10.x.x.x, that's your Mac.

Now, use that to connect to your local server on your Mac.

For me, it's usually something like

share|improve this answer

You must log in to answer this question.

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