Unable to connect to web server ‘IIS Express’

Enable/disable SSL

This is the easy fix. For me, toggling the “Enable SSL” setting in the project Debug tab inside Visual Studio (just change it to the opposite of what is currently set and run the project) has fixed the issue.

As I understand it, there are two reason this might work. First it causes Visual Studio to update the Applicationhost Config (more about that later). Secondly, sometimes the SSL address is bound. Therefore disabling SSL disables the problem.

Applicationhost Config

Open your $(solutionDir)\.vs\config\applicationhost.config file and ensure your site looks like this:

<site name="[YOUR PROJECT NAME]" id="3">
  <application path="https://stackoverflow.com/" applicationPool="Clr4IntegratedAppPool">
    <virtualDirectory path="https://stackoverflow.com/" physicalPath="//PATH/TO/YOUR PROJECT" />
  </application>
  <bindings>
    <binding protocol="http" bindingInformation="*:[YOUR_PORT]:localhost" />
    <binding protocol="https" bindingInformation="*:[YOUR_SSL_PORT]:localhost" />
  </bindings>
</site>

Make sure iplisten is configured to 0.0.0.0

If the IP listen list is not configured, this issue may occur (caution, I have no idea why).

Check netsh to ensure there is an entry for 0.0.0.0

PS C:\Windows\system32> netsh http show iplisten

IP addresses present in the IP listen list:
-------------------------------------------

::     
0.0.0.0

PS C:\Windows\system32>

Add the correct netsh rule if it does not exists. You’ll need an admin cmd.exe or admin PowerShell for this.

PS C:\Windows\system32> netsh http add iplisten ipaddress=0.0.0.0

Ensure nothing is binding to the address you are using

This seems to be an issue with Blazor for me. If an address is binded to the address Blazor is trying to use, this can cause issues. Use netsh again to check what is in use.

netsh http show urlacl

An entry that looks like this

Reserved URL            : http://*:50902/
    User: \Everyone
    Listen: Yes
    Delegate: No
    SDDL: D:(A;;GX;;;WD)

Can be deleted with this command

netsh http del urlacl url=http://*:50902/

Leave a Comment