How to access localhost from a Virtual Machine

At work I use a MacBook, but when testing customer-facing portions of our site I run Windows in a virtual machine instance that I downloaded from Microsoft so that I can test Internet Explorer compatibility.

The VM could access my network and the greater internet perfectly fine, but would not access “http://localhost:3000” from inside Internet Explorer. It took me awhile, but I found the solution using Stack Overflow (of course). Hopefully this saves someone some time. Also note, I’m running VirtualBox.

Link to StackOverflow solution:

1. Shut your virtual machine down.
2. Go to VirtualBox Preferences -> Network -> Host-only Networks -> click the “+” icon. Click OK.
3. Select your box and click the “Settings” icon -> Network -> Adapter 2 -> On the “Attached to:” dropdown, select “Host-only Adapter” and your network (vboxnet0) should show up below by default. Click OK.
4. Once you start your box up again, you should be able to access localhost at http://10.0.2.2/

Leave a Reply