Greg Rickaby

Engineering Leader / Full Stack Developer

· 2 min read · #code

Set up localhost on VirtualBox

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

  1. Boot up your virtual machine
  2. Navigate to C:\Windows\System32\drivers\etc
  3. Change permissions. Right click, Properties -> Security -> Advanced. Select Users ->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

  1. Enter the IP address of your localhost and the URL

Screenshot 2014-11-25 08.40.58

  1. Save changes
  2. Open a web browser 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

  1. 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.

Greg is the Director of Engineering at WebDevStudios. He also moonlights at Dummies writing and editing books. Follow him on Twitter for lots of pictures of pepperoni pizza and tidbits about Next.js.
· · ·