Skip to content

Instantly share code, notes, and snippets.

@justingarrick
Last active October 19, 2022 13:54
Show Gist options
  • Star 53 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save justingarrick/6322779 to your computer and use it in GitHub Desktop.
Save justingarrick/6322779 to your computer and use it in GitHub Desktop.
Expose IIS or IISExpress running in a Parallels Windows 7/8 VM to your OS X host

Expose IIS or IISExpress running in a Parallels Windows 7/8 VM to your OS X host

Rename your virtual machine

In your Windows 7/8 VM, go to Control Panel > System > Advanced system settings > Computer Name and click Change. Name this whatever you like, e.g. windows. Restart your VM.

Add an ACL rule

Open CMD or Powershell as administrator. Add a URL ACL entry for your new name on the port of your choice, e.g.
netsh http add urlacl url=http://windows:8080/ user=everyone

Add a firewall rule

Open CMD or Powershell as administrator. Add an inbound firewall rule for this new port.

In Windows 8, the syntax is:
netsh advfirewall firewall add rule name="IISExpressWeb" dir=in action=allow protocol=TCP localport=8080

In Windows 7, the syntax is:
netsh firewall add portopening TCP 8080 IISExpressWeb enable ALL

Configure the IIS binding

If you're using IISExpress, edit your applicationhost.config file, typically found at your Documents\IISExpress\config\applicationhost.config. Find your site under sites, and add a binding to the port using your machine name, e.g.

<bindings>    
	<binding protocol="http" bindingInformation="*:8080:localhost" /> <!-- This will be here already -->
	<binding protocol="http" bindingInformation="*:8080:windows" /> <!-- Add this -->
</bindings>

If you're using IIS, open IIS Manager, find your site under YourMachineName > Sites > YourSiteName. Right-click and select Edit Bindings.... Add a binding with the host name you selected in step 1, e.g. Type: http, IP address: All Unassigned, Port: 8080, Host name: windows. Click OK.

Restart IIS/IISExpress

Startup IISExpress with Visual Studio or restart IIS from IIS Manager and hit your URL from a browser on your Mac/VM Host, e.g. http://windows:8080

Sources

http://stackoverflow.com/questions/3313616/iis-express-enable-external-request http://stackoverflow.com/questions/5442551/iisexpress-returns-a-503-error-from-remote-machines http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx

@adamjmendoza
Copy link

I have a VM set up and I can reach it from the Mac OS with a browser and Postman but doesn't work with JMeter. Have you tried this using JMeter? (JMeter works fine with external URLs).
I get this error:

java.net.URISyntaxException: Malformed IPv6 address at index 8: http://[windows:52000]/
at java.net.URI$Parser.fail(URI.java:2848)
at java.net.URI$Parser.parseIPv6Reference(URI.java:3469)
at java.net.URI$Parser.parseServer(URI.java:3219)
at java.net.URI$Parser.parseAuthority(URI.java:3155)
at java.net.URI$Parser.parseHierarchical(URI.java:3097)
at java.net.URI$Parser.parse(URI.java:3053)
at java.net.URI.(URI.java:588)
at java.net.URL.toURI(URL.java:939)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:252)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1105)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1094)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:429)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:257)
at java.lang.Thread.run(Thread.java:745)

@PureKrome
Copy link

@justingarrick - would be soooooo awesome if there was a way to use powershell to set the site/bindings of your website ... in the IISExpress applicationHost.config file...

@arnimi
Copy link

arnimi commented May 2, 2015

Maybe I understood it wrong. I thought it is to be able to run it in your host computer browser.
Because it is working in my VM browser, but it's not in my Host computer browser.

Thank you.

@billyhunt
Copy link

This is amazing. I have been trying to make this work on and off for months. Thank you so much.

@miguelhughes
Copy link

Thank you for this!
My binding was not under Documents\IISExpress\config, but in the solution instead:
$(solutionDir)\.vs\config\applicationhost.config.

@donniefitz2
Copy link

I tried these instructions and it worked for the most part, but like @miguelhughes said, I had to edit the applicationhost.config in my solution's .vs directory. I also had to disable the Windows firewall completely for some reason.

@fusion27
Copy link

fusion27 commented Oct 13, 2017

Worked well for me using Windows10, thanks so much for posting @justingarrick! Take the rest of the day off! One difference between your solution and mine is that I shut off my VM Windows 10 Firewall altogether.

@modestotech
Copy link

modestotech commented Feb 20, 2019

After several failed tentatives this gist solved it for me.
On a Windows 10 installation I accessed /.vs/config/applicationhost.config in the project and I also added a redirect in /etc/hosts on the host: 10.211.55.3 windows and finally set the Project Url to http://windows:57480 in project settings in VS. Note that I've used 57480, not 8080.

@jackkranz
Copy link

@justingarrick cheers mate, this was super helpful :) !

@MacL3an
Copy link

MacL3an commented Feb 5, 2020

After spending days trying to get this to work this post finally saved me. THANK YOU. Hints that helped me:

  • Visual Studio 2019 doesn't always seem to use IIS Express as default. I kept doing changes to the config file but nothing happened, until I realised VS Project settings was set to "Launch Project", not Launch "IIS Express".
  • Even though I thought I had disabled the Windows Firewall (I had disabled it for Private and Domain networks), it didn't work until I ran netsh advfirewall firewall add rule name="IISExpressWeb" dir=in action=allow protocol=TCP localport=8080

@rossjbartlett
Copy link

After following these steps on Mac OSX Catalina, chrome browser was showing NET::ERR_CERT_REVOKED. The solution to this is to click within the page and type thisisunsafe. Apparently Apple introduced new requirements for SSL certificates to be accepted by Catalina.
Source: https://podtech.com/os/mac-osx/chrome-catalina-certificate-issue/

@lokilim
Copy link

lokilim commented Feb 11, 2020

Hi all, currently what i facing is session expired. I able to access to the page and everything, but when i work with function with session, it will lost the session, after refresh.

@guisantos
Copy link

Worked really well to me, thanks!

@backendeveloper
Copy link

Thanks bro, work done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment