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

  • designvote

    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

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

    • Renard Kabza

      Only this proxy works for me.

    • Mohit Hiralal

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

  • Sajith Kahawatta

    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

      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

        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!

  • Prefiero Figurados

    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.

    • 林柏億

      I have the same problem, but I found the solution:
      If your port number is 51603, you may have typed this:
      netsh http add urlacl url=http://*:51603/ user=everyone

      All you need to do is to delete the rule, so you can type:
      netsh http delete urlacl url=http://*:51603/

      Hope this solution can help you 🙂

  • Non Linear

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

  • SlothGod

    I know this might be a bit old, but to fix any issues with not being able to launch at all, try running this command:

    netsh http delete urlacl url=http://*.{port}/

    netsh has gained rights over IIS Express meaning IIS Express does not have permission to use this port