IIS Express – HTTP Error 400. The request hostname is invalid.
The following is the fix for the error “HTTP Error 400. The request hostname is invalid” when trying to browse an IIS Express site using a different host name or IP address.
1. Exit the IIS Express instant currently running.
2. Open IIS Express’s applicationhost.config located at the following path C:\Users\<user>\Documents\IISExpress\config\applicationhost.config
3. Find the entry for a particular site (e.g “Test” running in port 6306) which you are developing.
e.g.
<site name="FlickrTest" id="10"> <application path="/" applicationPool="Clr4IntegratedAppPool"> <virtualDirectory path="/" physicalPath="E:\Projects\BB Apps\FlickrTest" /> </application> <bindings> <binding protocol="http" bindingInformation="*:6306:localhost" /> </bindings> </site>
4. Replace the following
bindingInformation=”*:6306:localhost” with bindingInformation=”*:6306:*”
5. Save the file.
6. Start a command prompt in administrator mode and run the following command.
netsh http add urlacl url=http://*:6306/ user=Everyone
7. Now debug the site again and you should be able to access the url using IP address or host name.
cssbased
November 11, 2013 - 8:28 PM
thanks for sharing this but when bindingInformation changed VS2013 fails to load project till I revert changes
Yann
November 8, 2014 - 5:35 AM
Thank you so much for sharing. Worked perfectly for me.
Ori Livson
March 3, 2015 - 5:14 AM
You’re my hero!
I was stuck getting my android emulator to connect to my local host and after I got all the code right I was getting the same erro and this fixed it.
Thanks so much!
Space Monkey
May 29, 2015 - 6:50 PM
Fuckin thanks man, holy crap, you saved the little hair I have left in my balding head
Arni
March 8, 2019 - 3:37 PM
You may need to run VS as administrator in order to have anything other than “localhost” in the hostname.
Juanjo
July 5, 2021 - 8:17 PM
Thanks !, works for me !!