Accessing local sites on VirtualBox

One of the most frustrating things about setting up VirtualBox for the first time is setting up a local host. It isn’t immediately obvious, and finding documentation was difficult. When you know how to get it running, it’s easy.

Here’s how:

1. Set up your VirtualBox image as normal.

2. On the networking tab, make sure you have the primary network adapter set to NAT

3. Boot your VirtualBox image and open your ‘hosts’ file using Notepad. This can be found at C:\Windows\System32\drivers\etc

4. Add your host entry as it is found on your main machine. In this example, I’m using the my site’s development copy ‘timneill.local’. See below.

5. Save the hosts file and enter your address into the browser. You should see your locally served site.

This was tested using Mac OS X and VirtualBox running WinXP. There is no need to flush the DNS cache for Windows after WinME.

If there are any problems, leave a comment or send me an email.