Hit localhost on macOS From VirtualBox Windows 7 VM

Published: Dec 3, 2018
Updated: Nov 15, 2021

At work, everyone on my team has Macs, but the users of one of our apps use Internet Explorer 11 (IE). We obviously need to test in IE, but how? This is where a VirtualBox Win7 VM comes in handy.

Our app has a React front-end, so local development/testing is done on http://localhost:3000. But how do we hit this URL from the Win7 VM? I’ll show you, but first let’s setup the VM.

Import and Configure the Win7 VM #

  1. Install VirtualBox. If you get a permission error when installing VirtualBox, see this fix

  2. Download IE11 on Win7 VM for VirtualBox

  3. Unzip the VM then import it into VirtualBox:

     unzip IE11.Win7.VirtualBox.zip
     VBoxManage import "IE11 - Win7.ova"
    
  4. Increase CPUs to 2:

     VBoxManage modifyvm "IE11 - Win7" --cpus 2
    
  5. Increase video memory to 128MB:

     VBoxManage modifyvm "IE11 - Win7" --vram 128
    
  6. Attach an empty optical drive, which is required in order to install Guest Additions:

     VBoxManage storageattach "IE11 - Win7" \
     --storagectl "IDE Controller" \
     --port 0 \
     --device 1 \
     --type dvddrive \
     --medium emptydrive
    
  7. Install VirtualBox Guest Additions:

    1. Start Win7 VM
    2. If needed, default login password is Passw0rd!
    3. Menu Bar > Devices > Insert Guest Additions CD image…
    4. Open Windows Explorer > Computer > double-click the CD Drive, follow the prompts, then reboot

Hit localhost from the Win7 VM #

Okay, now let’s hit http://localhost:3000 from our Win7 VM.

Open Internet Explorer and navigate to http://10.0.2.2:3000. Bam, we can see our app.

You may be wondering, “how is this working?” In a nutshell, the default gateway of the Win7 VM, 10.0.2.2, is equivalent to localhost on macOS. See this superuser thread for a deeper dive.

You can confirm the default gateway of your VM by doing the following:

Network Adapter #

To hit internal (vpn-only) sites, keep your network adapter as NAT.

To hit external sites such as https://duckduckgo.com/ then set your network adapter as Bridged Adapter.

Reply by email