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”

  • 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.

  • 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).