Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 installed Apache on an Ubuntu VM. When I go into the guest and load up Firefox I can see that Apache is working fine when I browse to localhost.

I would like to access this same page through the host. I've tried using the IP address of the guest but nothing comes up.

Ideally I would love to set up my Windows 7 (host) to request of the Apache server on the guest. How can I do this?

share|improve this question
up vote 113 down vote accepted

If you other machines in your physical network must be able to reach your VM (or if the VM needs Internet access), use bridged networking. Otherwise, stick to host-only networking.

  1. Stop your VM and open its settings in the VirtualBox (OSE) Manager
  2. Go to the Network tab
  3. Select the network mode at your choice (bridged networking or host-only) (in the below example, I'm using host-only)

    If you want to use bridged networking, you've to select the right network adapter at Name. For wired connections, you'd select something named like eth0. Wireless connections are usually named wlan0 (the numbers may vary)

  4. Save the settings
  5. Start the Ubuntu VM
  6. When up, you can gather the IP address by running:

    ifconfig | grep addr

    In the below output, is the IP address that can be used in your Win7 host system to access your VM:

    eth0  Link encap:Ethernet  HWaddr 08:00:27:70:27:fe  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::a00:27ff:fe7b:25fe/64 Scope:Link
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
  7. In your windows host system, edit C:\Windows\drivers\etc\hosts as administrator and add a line:

    If you've a Ubuntu host system, edit /etc/hosts using sudo nano /etc/hosts

  8. Profit!
share|improve this answer
This worked perfectly for host-only networking and I can now access the guest from the host's browser. However with a bridged connection, which I would like, I don't have access to the internet from the guest. – drtanz Jul 7 '11 at 11:06
If anyone can help me out with the bridged connection that would be great, I don't know if I'm doing anything wrong, I just selected bridged and started up the guest, but didn't have any connection to the internet, neither from the host. – drtanz Jul 7 '11 at 12:11
ipconfig is not a command on Linux, it's ifconfig. Did you mean that? – Max Jun 18 '13 at 20:07
On windows 7/8 host file is here: C:\Windows\System32\drivers\etc\hosts – Dalen Oct 25 '13 at 10:01
@begueradj Those steps above apply to bridged networking but some networks do not allow/give you multiple addresses. On my uni, I could not use bridged networking because of that, in those situations I would use NAT with port forwarding instead. – Lekensteyn May 22 '14 at 14:43

In my case, I have a router assigning a static IP to my Host PC.

  1. Set the network adapter as Bridge:

    Settings > Network > Adapter 1 (Enable Network Adapter) > Attached to: (Bridge Adapter) > OK

  2. Start the Virtual Machine > log in

  3. Change the VirtualMachine's IP from dynamic to static

    sudo nano /etc/network/interfaces

  4. Under The primary network interface change the word dhcp to static and enter your new static IP or comment the line and add a new one


#iface eth0 inet dhcp
iface eth0 inet static

Notice my router is working at and yours could be at or or some else.

After you do that, you can have internet conection in both host and guest machine, and type that static IP in your web browser to check you apache server.

share|improve this answer
I forgot to say you have to make sure your /etc/hostname is properly configured this way: nameserver [your_isp_primary_dns] and nameserver [your_isp_secondary_dns] – Nuc134rB0t Jul 2 '12 at 12:58

Instead of trying to set the adapters to Bridged or Host Only Network Adapter, you can try Port forwarding under Firewall/ Other ports, with your port no set to tcp and udp connections.

share|improve this answer

If you cant connect over ip you're not likely to have any success with dns names on a default apache install.

check the network settings of the virtual host, I always putt it to bridged to it can be accessed throughout the entire network.

share|improve this answer
I set it to bridged but now the guest doesn't connect to the internet. – drtanz Jul 7 '11 at 10:58
do you get an IP in the quest OS? I usually set up multiple NIC's to match all my physical NIC's. Can you perhaps dump your ifconfig from the quest and host – PvdL Jul 7 '11 at 16:48
When I'm working with wireless it works but with cable no, here are some screenshots showing my config: – drtanz Jul 8 '11 at 9:41
any help on this please? – drtanz Jul 10 '11 at 21:58
it looks like your computer is directly connected to the internet and that may be the reason why your client isn't getting a IP (v4) – PvdL Jul 11 '11 at 8:36

The accepted answer did not work for me (I installed virutalbox inside ubuntu 12.04 LTSand inside virtualbox I installed ubuntu 14.04 LTS Server). I just swapped the network settings for Adapter1 and Adapter2 i.e. setting up Adapter1 for "bridged networing" and Adapter2 for "NAT" and it started working.

share|improve this answer
This was useful, but switch the adapter order so the guest uses NAT by default and be able to connect to the internet. – MadeOfAir Mar 30 '15 at 17:17
This actually worked for me. I'm trying to access a Windows VM from within a Mac Host. – benjaminz Jun 8 at 19:26

In bridged mode, if your host uses a static IP address, you should manually config your guest IP in the same range with the host IP. Otherwise, the guest will not be automatically allocated with a valid IP address. HTH.

share|improve this answer

Lekensteyn's answer is right. But if you are in a corporate environment, you might have to disable the proxy server for your guest's IP address. For example, if you are using Mozilla Firefox on your Host machine and you are trying to access on the guest, you need to go to Firefox's Tools->Options->Advanced->Network->Settings and use "No Proxy" or "No Proxy For ->".

share|improve this answer

If you need to access a guest which gets different IP due to use of DHCP, I suggest accessing via it's hostname. However accessing via hostname when the host is Windows might require an extra tool.

The following text was copied from my own answer at

I suggest you use Multicast DNS to fix this.

Ubuntu is using this by default via Avahi.

The Windows host needs an Avahi-client for it to discover other Avahi-services. If your host already uses some Apple software this is probably already there via a service called Bonjour. However, if this is not already installed then a small version of Bonjour is available for download here: Bonjour Print Services. After installation you should be able to access your guest via .local.

Note: The mDNS system seem to use the .local postfix by default. So, if your hostname is "", then the actual hostname will be "".

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.