skip to main content

Accessing localhost on Mac from a Windows Virtual Machine

02 June, 2020

Posted in popular code

As a frontend developer, it’s important to test your code on as many web browsers as possible, but as a Mac user it is necessary to run Windows in a Virtual Machine — in my case, VirtualBox — in order to test on Microsoft Edge and Internet Explorer.

Microsoft offers Free Virtual Machines from IE8 to MS Edge.

Out of the box, VirtualBox doesn’t have access to localhost from the host Mac, so you’ll need to follow these steps.

Exposing Mac localhost to Windows VM

On VirtualBox, make sure your network adapter is set to NAT. On your Windows VM, make sure you can access any public webpage (e.g.

Get your Default Gateway IP address for your Windows VM. To do so, click on the Windows start menu. Type Command Prompt in the search field. Open the program and type ipconfig.

Again on Windows VM, click on the Windows start menu. Type Notepad. Right-click on Notepad and select Run as administrator.

From Notepad, open C:\Windows\System32\drivers\etc\hosts. Add this line to the bottom: localhost
# Where is your gateway IP

You should now be able to access localhost on your Mac by visiting on your Windows VM.