Greg's Blog

moon indicating dark mode
sun indicating light mode

Set up localhost on VirtualBox

November 25, 2014

My local stack includes MAMP, VirtualBox and ModernIE. ModernIE is great for cross-browser testing, but you have configure your “hosts” file. Here are the steps to get localhost working through VirtualBox:

1) Click on “settings -> network” 2) Select “bridged adapter” from the dropdown

Screenshot 2014-11-25 08.37.00

3) Boot up your virtual machine 4) Navigate to C:\Windows\System32\drivers\etc 5) Change permissions. Right click, “Properties -> Security -> Advanced”. Select Users, and “Change Permissions”. Click “Full Control -> Ok”.

Screenshot 2014-11-25 09.22.23 6) Finally, open “hosts” with Notepad

Screenshot 2014-11-25 08.39.42

7) Enter the IP address of your localhost and the URL

Screenshot 2014-11-25 08.40.58

8) Save changes 9) Open Internet Explorer (or whatevs) and type in your address. Your localhost should now resolve.

Screenshot 2014-11-25 08.43.36


For testing on Ubuntu (via VirtualBox), you will need to bridge the network adapter and edit your host file as well. It’s much easier than on Windows!

1) After bridging the network adapter (like above) open Terminal, and type:

sudo nano /etc/hosts

Screenshot 2014-12-02 13.07.30

2) Enter the IP address of your localhost and the URL

Screenshot 2014-12-02 13.11.12

3) Save the changes ( CTRL + X + Y ) and exit

Screenshot 2014-12-02 13.15.14

That’s it!

**Note: If your localhost is setup for DHCP, you’ll probably need to update the hosts file with your new IP on a regular basis.

Image Source

Director of Engineering @WebDevStudios / Author & Editor @WileyGlobal. Read more about me.