Visual Studio 2019: "This site can’t provide a secure connection" on localhost

16,430

Solution 1

Repair of IIS Express fixed my problem:

enter image description here

Solution 2

Just as it did not work for @Nosnetrom - repairing IIS 10.0 Express did not work for me either. As @Julian mentioned my problem was caused by uninstalling VS 2017 as well.

This is what did not work for me:

  • uninstalling / re-installing VS 2019
  • installing VS 2017
  • uninstalling / re-installing / repairing IIS 10.0 Express

This is what worked for me:

  • after reading this advice - I realized that I was using port 51542 instead of a port in the range of 44300 through 44399 enter image description here
  • then I updated the applicationhost.config file according to this advice. The location of said file on my Windows 10 machine is: C:\Program Files (x86)\IIS Express\config\templates\PersonalWebServer\applicationhost.config. I had to open that file in Notepad ran as an administrator otherwise I could not save these changes: enter image description here
  • then in Visual Studio I created a new virtual directory enter image description here
  • that seemed to have done the trick for me - when I ran the application it worked enter image description here

Solution 3

For those who all the above methods didn't worked:

open a command prompt and then run:

dotnet dev-certs https --clean

and then:

dotnet dev-certs https --trust

Solution 4

None of the above solutions worked for me, Following steps worked for me. Go to chrome or edge browser and type chrome://net-internals/#hsts search for localhost in query domain, you will find lists of domain including localhost. Now delete the domain enter image description here

Delete the domain by typing localhost enter image description here

Solution 5

None of this worked for me. What did work (and it's not as drastic as the other answers)...

Go into web project and set Start URL and Project URL to this: https://localhost:44365/

Save (but don't run the Project).

Edit .vs/[ProjectName]/config/applicationhost.config and change the bindings for the web project to this:

<binding protocol="https" bindingInformation="*:44365:localhost" />
<binding protocol="http" bindingInformation="*:53269:localhost" />

Reopen Visual Studio and when I started the website it worked.

Share:
16,430
Julian
Author by

Julian

Full stack / backend developer, Tech lead, NLog maintainer and programming language development enthusiast.

Updated on June 07, 2022

Comments

  • Julian
    Julian almost 2 years

    I've installed Visual Studio 2019 and uninstalled Visual Studio 2017.

    Now if I start an ASP.NET (Core) site with https, it always say on Chrome:

    This site can’t provide a secure connection

    or on Edge

    Can’t connect securely to this page

    Screenshots:

    Chrome:

    enter image description here

    Edge:

    enter image description here

    The URLs are correct. This also the same http://localhost:56784/ (it redirects to https)

    enter image description here

    Tried

    What I've tried:

    • Updated Visual Studio 2019
    • Create a new ASP.NET Core 2 website
    • Tested with a ASP.NET site (non core)
    • Remove IIS certificates with MMC
    • Checking/changing the IIS settings in Visual Studio 2019 (project properties with context menu and project properties with F4)
    • Searching on Stackoverflow & Google ;)
    • Repair Visual Studio 2019

    Issue

    I think the issue is introduced by:

    • Installing Visual Studio 2019 and/or,
    • Uninstalling Visual Studio 2017 and/or,
    • Updating Windows 10 (current Version: 10.0.18362 Build 18362)

    The underlining issue looks like a wrong/old/not supported TLS version?

    Question

    What can I do to diagnose/fix the problem?

  • Canada Wan
    Canada Wan over 3 years
    Thanks for having saved my life!
  • Nosnetrom
    Nosnetrom over 3 years
    I have both VS2017 and VS2019, and I have OP's same problem with VS20129. I can't repair IIS Express 10, because my installed version is more recent than the version I downloaded from MS. :-P Any suggestions?
  • AtLeastTheresToast
    AtLeastTheresToast over 3 years
    Give this man a medal! This is the only thing that worked for me VS2019 Community on a new machine.
  • Julian
    Julian over 3 years
    This is just guessing. A Secure connection (TLS) is on the presentation layer (or lower), and http (cookie) a least a layer higher, on the application layer. See OSI model
  • Julian
    Julian over 3 years
    What do you mean with "reload permanent deletion"?
  • Mustafa Yıldırım
    Mustafa Yıldırım over 3 years
    I mean, Empty Cache and Hard Reload
  • aj go
    aj go about 3 years
    what if I'm using swagger? will this approach work? I'm having issue since swagger is using http protocol..
  • aj go
    aj go about 3 years
    I'm getting error in repairing IIS..its like looking for a file..
  • Dominic Isaia
    Dominic Isaia about 3 years
    Thank you so much for this solution. This saved me a lot of headache.
  • Julian
    Julian almost 3 years
    But then you will use http instead of https after this step?
  • Julian
    Julian about 2 years
    is this the same answer as from Bashar Abu Shamaa / Mar 22 2021 at 14:52? Please update that one!
  • Smitty-Werben-Jager-Manjenson
    Smitty-Werben-Jager-Manjenson about 2 years
    This worked for me. Not sure how it got unchecked, but thank you!
  • Smitty-Werben-Jager-Manjenson
    Smitty-Werben-Jager-Manjenson about 2 years
    This worked for me running an older ASP.NET app in VS2022. In a more modern .NET Core MVC app, I simply had to enable SSL.