I have installed VirtualBox 5.0.14 on an Lubuntu 15.10 host, and created a virtual machine with Lubuntu 14.04.5 LTS as the guest OS.

I would like to set up a host-only network adapter in VirtualBox so that I can access an Apache webserver running inside the guest OS from a webbrowser running on the host system.

So far I have created a host-only adapter vboxnet0 which I can ping successfully from the host OS. However, I cannot access port 80 using a webbrowser or any other means.

What can I do to get to the cause of the problem and configure things properly?

VM network settings

enter image description here

VirtualBox vboxnet0 settings

enter image description here

enter image description here

Test results inside guest

After booting the VM and starting Apache (using sudo service apache2 start) I can access a test page on http://localhost/ using Firefox inside the guest OS without problems.

The corresponding Apache VirtualHost is defined as <VirtualHost *:80> in /etc/apache2/sites-enabled/000-default.conf, so I don't see why it wouldn't be accessible from any host.

Also, sshd and MySQL server are running on the guest. I can ssh to localhost and nmap shows all relevant ports open (22, 80, 3306).

Test results on host

On the host OS, vboxnet0 appears as follows and is pingable:

% ifconfig vboxnet0
vboxnet0  Link encap:Ethernet  HWaddr 0a:00:27:00:00:00  
          inet addr:  Bcast:  Mask:
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:192 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:16176 (16.1 KB)

% ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=0.023 ms

However, none of the ports are accessible:

% nmap -p 22,80,3306

Starting Nmap 6.47 ( http://nmap.org ) at 2016-08-20 21:29 CEST
Nmap scan report for
Host is up (0.000027s latency).
22/tcp   closed ssh
80/tcp   closed http
3306/tcp closed mysql

Nmap done: 1 IP address (1 host up) scanned in 0.07 seconds

Trying to match IP address

As per comment by @MarkoPolo:

Even though is pingable from the host OS, I cannot access this IP address from the guest OS.

In fact, the guest OS has an IP address from the DHCP range specified in for vboxnet0:

eth1      Link encap:Ethernet  HWaddr 08:00:27:0d:b4:6a  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::a00:27ff:fe0d:b46a/64 Scope:Link
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1180 (1.1 KB)  TX bytes:1422 (1.4 KB)

The IP address is not reachable from the host OS, i.e. not pingable, no access using webbrowser.

I tried updating the IP address of eth1 to using ifconfig. Then, Apache is reachable on from the guest OS, however, still no access (aside from ping) is possible from the host OS.

  • 1
    From within the guest, can you access Apache on, rather than localhost? – Mark Riddell Aug 20 '16 at 19:56
  • @MarkoPolo I updated the question – tmh Aug 21 '16 at 5:44

Shorter answer.

Based on what I know about default VirtualBox network settings, your host only connection that uses is on the incorrect subnet and that adjustment is being done in the wrong area to get this thing working.

When setting up a host only adapter on the host OS, the IPv4 address should be And then—after that is setup—on the guest OS set the eth1 interface to use an IP address like

Longer answer.

When using VirtualBox the internal pseudo-software router is set to work on the 192.168.56.x range of IP addresses. The DHCP server range—which you should not set static IP addresses on would be in the range of to and to set a static IP address, you would need to set an IP address between to So I would recommend that your guest OS config use (Lubuntu 14.04.5 LTS) use an IP address such as

But don’t set that value in the “Adapter” area as you have it set up. Instead, adjust your adapter settings to be as follows; see Mac OS X screenshot below for reference:

  • IPv4 Address:
  • IPv4 Network Mask:
  • IPv6 Address: [Leave Blank]
  • IPv6 Network Mask Length: 0

Screenshot of the network settings for a host only interface in the Mac OS X version of VirtualBox.

And then on your guest OS (Lubuntu 14.04.5 LTS), it seems odd to me that your eth1 setting would be the DHCP setting and have the address of I use Ubuntu 14.04.5 with a very similar host only connection for Apache development on the second adapter as well, and my setup is broken down like this:

  • eth0 with an IP address of
  • eth1 with an IP address of

And my settings in /etc/network/interfaces are as follows:

auto eth1
iface eth1 inet static

So double-check that IP address on the host only connection and double-check your network interfaces config as well.

| improve this answer | |
  • Thanks a lot for your answer. Actually, I just figured out the answer to my own question the moment before I saw your answer. :) – tmh Aug 21 '16 at 6:47

The purpose of Host-only networking using VirtualBox

In your example, you're attempting to set up a host-only network in VirtualBox that consists of one guest machine only, and of course the host machine.

Keep in mind, however, that Host-only networking is designed so that it can accommodate multiple guest machines. All guest machines inside the host-only-network can communicate with eath other and the host machine but not with the outside world:

Outside world <--> NIC <--> Host <--> vboxnet0 <--> virtual NIC <--> Guest OS
                   ---                --------      -----------
                                                   (virtual NIC <--> Guest OS #2)
                                                   (virtual NIC <--> Guest OS #n)

Distinguishing between host and guest IP address

Your assumption is that would be the IP address of the guest OS because it appears as vboxnet0 on the host machine.

This assumption is incorrect -- in fact, is the IP address of the host machine! Assume that you have multiple guest machines inside your host-only network, then all of them could access the host OS using that IP address.

vboxnet0 acts as the gateway between host and guest(s). You can easily verify this: If you open any port on your host machine (for instance using nc), you should be able to access that port from the guest OS on

The actual IP address of the guest is -- as you noted above -- which is taken from the DHCP configuration in VirtualBox' vboxnet0 settings. This is what is to be expected. You should be able to access your guest OS on from the host.

(Note that this is where the multiple guest machines would come into play: If you would assign more guest machines to vboxnet0, the would also get IP addresses from the DHCP range specified. You can also choose to assign static IP addresses, however, keep in mind then that they must be in the same subnet as the host's IP address, i.e. the address of vboxnet0.)

Possible cause of trouble and solution

Your guest machine should be reachable as, which you describe does not work. The VirtualBox configuration looks good. You're more likely facing a routing/subnet problem (that may have to do with other network interfaces on your host machine).

Try putting the host machine in the same subnet as the guest machine(s), by changing VirtualBox' settings as follows:

enter image description here

Check the routing table on your host machine using route. A route to / via vboxnet0 should now exist, created by VirtualBox.

You should now be able to access the guest's Apache from the host via and -- if neccessary -- access the host machine from the guest via

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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