Enable external request on IIS Express

I was working on Asp.net MVC application and had to test it from another machine. By default, IIS Express doesn’t allow remote connections and you will get an error ‘Bad Request – Invalid Host Name’ .In this post, I will explain how to enable external access to IIS express

Step 1 : Configure IIS Express


For Visual Studio 2015,  open file <solution>/.vs/config/applicationhost.config and localhost in ‘bindingInformation’ to ‘*’.  After making changes, it should like below

HTTP Binding

Step 2: Allow URL Access


  • Open command prompt in ‘Administrator’ mode
  •  Run following command

Note: Run this command with your IIS listening port. In my case above, application was listening on port 51603

Step 3: Configure Firewall Port


  •  Go to the “Control Panel\Windows Firewall”
  • Click “Advanced settings”
  •  Select “Inbound Rules”
  • Click on “New Rule …” button
  • Select “Port”, click “Next
  • Fill your IIS Express listening port number, click “Next”

Inbound Rule

  • Select “Allow the connection”, click “Next”
  • Check where you would like allow connection to IIS Express (Domain, Private, Public), click “Next”
  • Enter rule name and click “Finish”

 

IMPORTANT: For latest version of visual studio, please read solution details in comments below

(Visited 9,713 times, 13 visits today)

Comments: 9

  1. designvote November 23, 2016 at 8:32 pm Reply

    Another, simpler option is to use the Visual Studio extension ‘Conveyor’, which does everything for you without touching any configuration files or your project. https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti

    • blakshmikanth November 24, 2016 at 9:22 am Reply

      Makes it easy for testing. Great tool, thanks for sharing.

    • Renard Kabza March 2, 2018 at 11:26 pm Reply

      Only this proxy works for me.

    • Mohit Hiralal March 6, 2019 at 10:41 am Reply

      The solution mentioned in this post did not work
      Conveyor did the trick for me. Thanks a ton!

  2. Sajith Kahawatta March 23, 2017 at 12:07 pm Reply

    I’m using VS 2015 Update 1. When I do exact as this post, It creates another set of “site” elements with localhost. What works for me was adding another binding with ‘*’ or IP address without changing existing binding (have both binding elements).

    • Dr.StrangeLove October 23, 2017 at 1:52 pm Reply

      this! The author should update the article to specify this. otherwise, you’ll have to modify the settings every time you restart the project

      • Jared Rypka-Hauer August 4, 2018 at 6:29 am Reply

        Yeah, this worked for me too… the rest of these instructions were golden… this was the only change I made to my configuration.

        Hats off to both Sajith and Lakshmi!

  3. Prefiero Figurados November 13, 2017 at 2:01 am Reply

    WARNING ===> Working with Visual Studio Community 2017… this really screwed things up. Now I can’t get the site to launch at all. Super frustrated. Wished I’d looked at the comments before screwing up my local config by following these instructions.

  4. Non Linear October 19, 2018 at 12:43 pm Reply

    If you have the local IIS already running then the netsh command for wich IIS will be issued? IIS or IIS express?

Leave a Reply

Your email address will not be published. Required fields are marked *