← All articles
Ubuntu · VirtualBox · Networking

Accessing a VirtualBox Guest Service from the Host

A service listening on localhost inside a virtual machine is isolated from the host by default. To reach a guest service from the host, the VM needs a network interface that provides host-to-guest connectivity and the service must listen on an address reachable through that interface.

This article documents a VirtualBox host-only networking configuration used with an Ubuntu guest on macOS.

Version context: VirtualBox menu labels, guest interface names, and networking behavior can differ across versions and operating systems. Verify the current VirtualBox networking documentation for a new setup.

Configure a Host-Only Adapter

  1. Shut down the virtual machine.
  2. Open the VM's Settings → Network.
  3. Enable Adapter 1.
  4. Set Attached to to Host-only Adapter.
  5. Review the advanced settings required by your environment.
  6. Start the virtual machine.

Find the Guest IP Address

Inside the guest, inspect the network interfaces. The original environment used ifconfig; newer Linux distributions commonly use ip addr as well.

Identify the IP address assigned to the host-only interface.

Connect from the Host

From the host computer, access the service using the guest's host-only IP address, for example:

http://<guest-ip-address>

If Apache or another web server is running in the guest and listening on the appropriate interface, the host should be able to reach it.

Troubleshooting

If the connection fails, verify that the guest service is running, that it is not bound only to 127.0.0.1, that the guest firewall permits the connection, and that the host-only adapter has a valid IP configuration.

Takeaway

Host-only networking creates a private path between the host and guest without requiring the guest service to be exposed directly to the external network. It is a useful pattern for local development environments and isolated testing.

CONTINUE READING

Explore closely related architecture, integration and implementation topics.