Windows – Access Windows Virtual Machine Localhost from Host Mac

Networkvirtualizationvmwarewindows

I have a Windows 8.1 virtual machine (VMWare Fusion 6) running on my Mac (OSX 10.9.4). In windows, I am running a site using IIS Express on a specific port. On the windows vm, I can write localhost:XXXXX as my address and get the page.
However, the localhost is different on my Mac than it is on Windows, and thus I can't simply write localhost:XXXXX on the mac. I currently have the network to "Share with my Mac" on the virtual machine settings.
What do I need to do to access the windows server from the mac?


Update

For those finding this page using Visual Studio 2015 and Windows 10, there appears to be a difference in how IIS Express works, and this solution no longer appears to solve the issue.

Update 2

I have this working now with Visual Studio 2015. The config files for the web application are now stored with the project/solution itself instead of old location in your documents folder. In the solution folder, there is a folder called .vs, and inside that, you need to navigate to the config folder. That's where the applicationhost.config is.
After that, I had to update my firewall to let IIS through (something changed where the old permission no longer worked, not sure if it's a quirk on my machine or not). Then, every thing else is as it has been described in the answer below.

Best Answer

There is a major difference in using IIS Express and the 'regular' IIS. The latter as installed by default in Windows.

In short, IIS Express runs sandboxed on its host environment. This means by default it cannot be accessed outside. Luckily, you're not the only one asking this as it has been adressed on StackOverflow several times. In my opinion, with this post having one of the better answers.

For future reference, this means:

  1. Edit the applicationhost.config file (which holds info and bindings to all your IIS Express projects ever ran locally)
  2. Execute the netsh http add urlacl url=http://*:8080/ command (possibly some other)
  3. Open up the Windows Firewall to allow IIS Express and the desired ports to be accessed 'externally' (yes, your Mac = external, as far as Windows is concerned)

As a final tip I'd like to suggest to also add your Windows' system name to the Mac host file. This can easily be done running the following command in the OSX Terminal:

sudo nano /etc/hosts

By adding the Windows system name you can now use it to navigate to http://your-win-name instead of having to point to an IP Address.

Good luck!