IIS Express URL Binding Error - how to fix
Sometimes when you start your solution in IIS Express you might see this error:
WTF?
This actually reminded me that I blogged about a similar issue 7 years (!) ago. Back then the issue was that IIS Express was not listening to ::
IPv6 address.
This time the issues is a different one.
Luckily there is a solution but with a caveat, read below for explanation.
Turns out that the port I was going to use was “promised” by the system to Docker services. The fix is to tell the system to exclude the specific port number from this process.
Solution
Step 1.
Run the administrative powershell and check that your port falls into one of the “promised” ranges:
netsh interface ipv4 show excludedportrange protocol=tcp
My port 65326
was there.
Step 2.
The solution in the SO answer was about disabling Hyper-V completely and then applying the fix.
I didn’t want to disable Hyper-V, who knows what happens if you do that?.. I didn’t want to uninstall Docker either.
Instead, I rebooted the system and before Docker has started I ran the following command in administrative powershell:
netsh int ipv4 add excludedportrange protocol=tcp startport=65326 numberofports=1 store=persistent
Step 3. Verify
Run the “show” command again and check that your port is in the exclusion list.
PS C:\WINDOWS\system32> netsh interface ipv4 show excludedportrange protocol=tcp
Protocol tcp Port Exclusion Ranges
Start Port End Port
---------- --------
49152 49251
49271 49370
...
64512 64611
65221 65320
65326 65326 *
65327 65426
65427 65526
* - Administered port exclusions.
Run the application in IIS Express and this time it should start without issues.
Let me know in the comments if it helped!