Server Fault is a question and answer site for system and network administrators. 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 have Ubuntu 11.0.4 installed as a guest OS under VirtualBox on OS X Lion. I installed Apache and tested the server from Firefox on the guest. Now I'd like to connect from the host.

I followed instructions from two sources without success. From VirtualBox, add rule in the Terminal of the host:

VBoxManage modifyvm Ubuntu --natpf1 "apache,tcp,,8888,,80"

shut down Ubuntu

under Settings > Network Bridged Adaptor tried both en1: Wi-Fi and en0:ethernet

Restart VirtualBox

Restart Ubuntu

Remember to Allow from all in /etc/apache2/sites-available/default

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
    # Allow from ::1/128

Restart Apache

Safari: Safari: +/- :8888/

Doesn't say can't find server, but times out

The second approach from here:

Modify ~/Library/VirtualBox/VirtualBox.xml on the host added these to the top of the file under ExtraData

ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" value="2222" ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" value="22" ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" value="TCP" ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/HostPort" value="8888" ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/GuestPort" value="80" ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/Protocol" value="TCP"

No go. Any ideas what to try next? Thanks.

@Eric Fortis Tried going back to NAT. In the guest:

te@VB:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:88:33:a4  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::a00:27ff:fe88:33a4/64 Scope:Link
          RX packets:69 errors:0 dropped:0 overruns:0 frame:0
          TX packets:91 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:27935 (27.9 KB)  TX bytes:11313 (11.3 KB)

lo        Link encap:Local Loopback  
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:480 (480.0 B)  TX bytes:480 (480.0 B)

In the host, neither nor works.

Update: Trying bridged mode: Attached to: Bridged Adaptor Name: en1: Wi-Fi (Airport) Promiscuous mode: Allow all Cable connected: unchecked

In the guest:

te@VB:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:88:33:a4  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 

No ip address?


Figured it out. I had Apache configured wrong for the new port. I used NAT with this from Terminal:

VBoxManage modifyvm Ubuntu --natpf1 "server,tcp,,8080,,8080"

I needed to modify ports.conf to add

> NameVirtualHost *.8080 
> Listen 8080

and sites-available/default to add

<VirtualHost *:8080>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all

It comes from trying to learn too many new things at once. Thanks for your patience.


migration rejected from Dec 16 '15 at 9:55

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by Ward, mdpc, ptman, MadHatter, HBruijn Dec 16 '15 at 9:55

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

is apache in your vhost configured to listen on the correct ports? this will work in bridged or nat mode, also check any firewall rules in the guest and that network access works out of the guest as well – anthonysomerset Aug 13 '11 at 0:19
I forgot to listen on the new port (8888), but now that I added the Listen 8888, it still doesn't work. I'll have to work on the other stuff. Thanks. – telliott99 Aug 13 '11 at 1:24
up vote 1 down vote accepted

The easy way to do this is to use the VirtualBox GUI under Settings, Network, Port Forwarding to create a port forwarding pair for each port that you need to have access to on the guest OS such as ssh, http, etc.

Didn't actually use the GUI, but this is basically what I did. I had Apache configured incorrectly. – telliott99 Aug 14 '11 at 14:30

It is easier if you have your guests network adapter configured for bridged mode. Ensure that your guest has an IP address in the same network as your host machine, you can use the ifconfig command to check, make a note of the IP address of your guest.

To access your guest from your host you can use http://ipaddress:8888 or you could edit the hosts file and add an entry for your guest so you can access it by name.

Trying bridged mode, I don't see an ipaddress when doing ifconfig in the guest. – telliott99 Aug 13 '11 at 14:40
The DHCP server on your LAN has to be configured to give your guest an IP address, or you have to give your guest a static IP address. Here is a link to configuring a static IP address.… – Iain Aug 13 '11 at 15:00
Thanks for the ideas. Lack of an IP address seems highly suggestive. However, I did follow the instructions in the link, and not only did it not work, now in the Control Center pressing the Network Connections button fails to bring up the next window, so there doesn't seem to be a way to reverse what I did using the GUI. I'll have to go to command line tools to fix that, I guess. – telliott99 Aug 13 '11 at 20:15
Never mind, fixed by reboot. I'll try to figure it out. Thanks again. – telliott99 Aug 13 '11 at 20:18
ifconfig eth0 down ifconfig eth0 netmask up. Set the IP address and netmask to suit . – Iain Aug 13 '11 at 20:18

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