Testing macOS localhost from Windows VM in Virtualbox

- 1 min

When developing any website, it is essential to test your changes on old versions of Internet Explorer. IE ships out of the box on Windows and Microsoft sold well over a billion copies of Windows. There are plenty of tools that promise to take the hassles of running virtual machines locally, but older versions of IE had a horrible debugger, and it is quite painful and slow to debug website over a video stream.

Microsoft provides freely downloadable virtual machines1 that are compatible with VirtualBox, Vagrant, Parallels, HyperV, and VMware to test and do QA in IE/Edge browsers.

Share Mac Localhost with Windows VM

In my example, I use Virtualbox, but the step should work the same way in any other virtualization software.

In VirtualBox settings, check if the network adapter is set to NAT.

VirtualBox NAT Settings

Note your gateway IP on your Windows VM. You can do this by opening in command prompt and typing ipconfig.

Default Gateway ipconfig

By default, Windows does not permit users to modify system files. Open C:\Windows\System32\drivers\etc folder and change the permission of hosts file such that your user has access to write that file.

allow full write permission windows

Now open C:\Windows\System32\drivers\etc\hosts file in Notepad and add your gateway IP address at the end of the file.

set gateway ip hosts file

You should now be able to access your Mac’s localhost on your Internet Explorer virtual machine. Happy debugging!

  1. These VMs stop working after 90 days, but you can efficiently work around it, by taking a snapshot after first importing the VM. 

Thilak Rao

Thilak Rao

Frontend ninja at Booking.com. I love working on TypeScript, Node.js, React during my free time. I have a slight obsession with UX and Web Performance.

rss facebook twitter github youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora