The fix for when The site can't be reached ERR_CONNECTION_REFUSED error

All of sudden when you receive an error when running an MVC app from Visual Studio 2022 and IIS Express is throwing an ERR_CONNECTION_REFUSED error.

 

In short

  1. Open cmd with admin rights
  2. Navigate to “C:\Program Files (x86)\IIS Express”
  3. Run IisExpressAdminCmd.exe setupsslUrl -url:https://localhost:PORT/ -UseSelfSigned changing PORT for the port you're trying to use.
For example, for the SSL URL https://localhost:44368/

c:\Program Files (x86)\IIS Express>IisExpressAdminCmd.exe setupsslUrl -url:https://localhost:44365/ -UseSelfSigned

Share item with friends