Hit localhost on macOS from VirtualBox Win7 VM
| Lastmod: 2019-05-08
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 #
- Install VirtualBox. If you get a permission error when installing VirtualBox, see this fix
- Download IE11 on Win7 VM for VirtualBox
Unzip the VM then import it into VirtualBox:
unzip IE11.Win7.VirtualBox.zip VBoxManage import "IE11 - Win7.ova"
Increase CPUs to 2:
VBoxManage modifyvm "IE11 - Win7" --cpus 2
Increase video memory to 128MB:
VBoxManage modifyvm "IE11 - Win7" --vram 128
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
Install VirtualBox Guest Additions:
- Start Win7 VM
- If needed, default login password is
- Menu Bar > Devices > Insert Guest Additions CD image…
- 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:
- Open Command Prompt or PowerShell
Look for the line that says Default Gateway
Default Gateway . . . . . . . . . : 10.0.2.2