Search code examples
windowsasp.net-coreiis-express

Can't run debugging on previously used port on IIS Express


recently I decided to move my ASP NET Core solution to new place, and obviously, something went wrong.

In launchSettings.json file there were specified:

"iisExpress": {
  "applicationUrl": "http://localhost:53985",
  "sslPort": 44325
}

When I moved whole solution, together with this file, I got connection reset error (yes, it was for SSL).

When I changed it to something new, eg. 44330, it worked.

Using netsh http show sslcert I see that there 44330 is specified, but 44325 isn't. So why I can't re-use it?

After moving many projects frequently, I will run out from ports to use! What's the remedy for that?


Solution

  • Copied from comment with more details.

    Requests to http://localhost:44325 can be reset if HTTP.sys cannot find a valid certificate bind to that port. Since you confirmed with netsh that indeed such a certificate is missing, we then know the exact cause of the reset error.

    The initial certificate mapping was created for 44300-44399 by IIS Express installer, so VS always assumes port 44325 has a certificate associated. However, it is pretty difficult to tell why now the certificate mapping is missing, as anything can change HTTP.sys settings.

    The solution is to recreate a certificate mapping with netsh for port 44325 (you can refer to other certificate mappings to learn what parameters you need).