Accessing your local environment from a Windows VM (tutorial)

Filing under: not very interesting but very useful (I hope) tutorials, here’s a step-by-step guide to accessing your local server (ex. the one you’ve got running on localhost:3000).

Why might you need this?

Because you need to test on IE and you have a not-Windows machine. Cool? Moving on.

Getting the VM

Download your VM for the OS/IE combination you need from the VMs page of modern.ie. This tutorial uses VirtualBox which is (hooray!) free to use.

Update the hosts file so you can access your local server

Step 1: Open Notepad as an administrator:

01-open-notepad-admin
Step 2: Confirm scary security box

02-run-as-admin

Step 3: Open the hosts file

Choose “Open” and find the hosts file. It’s at C:\Windows\System32\drivers\etc. Be sure to “show all” file endings, as you won’t see the hosts file otherwise (it doesn’t end in .txt!)

03-open-hosts-file

Step 4: Edit the hosts file to at 10.0.2.2 with some name

Don’t name it localhost because weird things will happen. And don’t forget that you still need to put the port when you’re accessing your server, mysite.com won’t work in your VM, but mysite.com:3000 will if that’s the port for your local server.

04-edit-hosts-file

Where’s 10.0.2.2 come from? Using the command prompt, you can run ipconfig to see your external host is 10.0.2.2 (or something different if this tutorial didn’t work at this point).
04a-check-ipconfig

5. Take a snapshot of your machine

Save your machine state. Run your VM from this snapshot to lock it in time when you had this set up, which should also prevent the VM self-combust clock from running (the Windows licenses are only good for so long).

05-take-snapshot

Hope this helps others! Shoutout to my colleague Dave for reminding me how to get this done a while ago, and now there’s a blog post for everyone else to benefit 🙂

Tags: , , ,

No comments yet.

Leave a Reply