This tutorial taught me how to create an Ubuntu Server (12.10, 64-bit) VM in VirtualBox on a Windows 7 host machine, install Apache and have it serve a site from a dummy domain accessible via the host machine's browser.

It took a day and many attempts (although it seemed I was following the instructions as they were laid out, I was always doing something wrong) and I'd finally done it.

I find Ubuntu as a much seamless development environment than Windows, and so I wanted to same thing on Ubuntu. So, this time, I created an Ubuntu Server VM in VirtualBox on Ubuntu host machine, installed Apache and configured it. But when I access the site via the dummy domain, I get the 'Server not found' error.

Yes, I did modify the /etc/hosts file just as mentioned in the tutorial (which is for Windows 7). But I couldn't get it to work. Don't know what's wrong. Anyone know what else I should be doing?

EDIT: If I am not clear enough, please ask. I am willing to clarify.

| improve this question | | | | |
  • Do you want to use the server from your computer (for example to develop) or from others in the network? – Davisein Nov 28 '12 at 16:04
  • The server is installed in a virtual machine (using virtualbox), and I want to access the test website served by the server from a browser on the host machine. Hope that's clear. I've posted the answer by the way (but can only mark it as answered after 2 days). – its_me Nov 28 '12 at 16:17
  • 1
    Sure, I have already upvoted your answer which is very good (btw). I just wanted to recommend you to add both host-only and bridged (for internet access). And also the other answer is a requirement in a bridged envirnonment if you want to access to the VM from the outside. To make the question fully clear for others ;) – Davisein Nov 28 '12 at 16:25

If you need to allow other machines in your physical network 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 the settings for it in the VirtualBox (OSE) Manager

  2. Go to the Network tab

  3. Select the network mode at your choice (bridged networking or 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:

    sudo ifconfig

    The output should look similar to this:

    eth0      Link encap:Ethernet  HWaddr 08:00:27:f4:c3:7b  
              inet addr:  Bcast:  Mask:
              inet6 addr: fe80::a00:27ff:fef4:c37b/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:20 errors:0 dropped:0 overruns:0 frame:0
              TX packets:25 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:3244 (3.2 KB)  TX bytes:2512 (2.5 KB)
    lo        Link encap:Local Loopback  
              inet addr:  Mask:
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:16436  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:0 
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

    In the above output, (on the second line) is the IP address that can be used in your Ubuntu host system to access your VM.

  7. Now open the hosts file in Ubuntu host machine:

    sudo gedit /etc/hosts

    (If you don't want to use gedit, replace the word with the name of your favorite editor. E.g. vim, nano.)

    Once the file is open, add this line, and save it:   my-dummy-site.com
  8. Open any browser on your host machine and go to my-dummy-site.com to access your website, served right from VirtualBox.

( Special thanks to @iSeth for the help. Entirely based on this answer, bit is NOT the same. )

| improve this answer | | | | |
  • 1
    This solution should work. I'm trying a development server with this config right now. Additionally both bridged and host-only can be used at the same time. Bridged do not allow the hosting machine to reach your own server (as far as I know). And the host-only does not allow access to internet (so no updates). I usually use both – Davisein Nov 28 '12 at 16:04
  • 1
    @Davisein Wrong. Bridged network mode allows your virtual machines to be accessed from the host machine, while also giving it (VM) access to the Internet connection used by the host. :) – its_me Sep 9 '13 at 10:57
  • True. I don't delete my previous comment so that yours don't look weird but it's wrong. The system that does not allow the hosting and the guest machine to talk is NAT as said here virtualbox.org/manual/ch06.html. – Davisein Sep 11 '13 at 9:37
  • Make sure IPTables isn't blocking the connection... – Ethereal Jun 10 '14 at 13:35
  • I followed these instructions to a T. If I open a browser on the Ubuntu VM, it is able to resolve the dns and serve my-dummy-site.com. However, if I open a browser outside of the Ubuntu VM (on my Windows 10 machine where I have my VM installed), it is not able to resolve my-dummy-site.com. It is able to resolve the IP though! What could be the problem? – Chris Nielsen Aug 23 '17 at 22:50

Only root can open ports < 1024, so if a regular user is running VirtualBox it won't open port 80 on Host and forward it to the Guest.

You can allow programs to open privileged ports by running:

setcap 'cap_net_bind_service=+ep' /path/to/executable

I don't know the path to the VirtualBox executable, but you can easily figure it out searching for something similar to "VirtualBox" in the output of ps auxf.

| improve this answer | | | | |
  • I will try it out and let you know. Meanwhile, you said that "Only root can open ports < 1024", but I was still able to get it to work (please see my solution below). – its_me Nov 28 '12 at 13:48
  • @its_me it's because your solution makes use of bridged networking. – Eric Carvalho Dec 28 '12 at 2:19
  • Ah, okay. Thanks for the clarification Eric. :) – its_me Dec 29 '12 at 16:55

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.