Visual Studio 2019: "This site can’t provide a secure connection" on localhost
Solution 1
Repair of IIS Express fixed my problem:
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
- 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: - then in Visual Studio I created a new virtual directory
- that seemed to have done the trick for me - when I ran the application it worked
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
Delete the domain by typing localhost
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.
Julian
Full stack / backend developer, Tech lead, NLog maintainer and programming language development enthusiast.
Updated on June 07, 2022Comments
-
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:
Edge:
The URLs are correct. This also the same http://localhost:56784/ (it redirects to https)
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 over 3 yearsThanks for having saved my life!
-
Nosnetrom over 3 yearsI 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 over 3 yearsGive this man a medal! This is the only thing that worked for me VS2019 Community on a new machine.
-
Julian over 3 yearsThis 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 over 3 yearsWhat do you mean with "reload permanent deletion"?
-
Mustafa Yıldırım over 3 yearsI mean, Empty Cache and Hard Reload
-
aj go about 3 yearswhat if I'm using swagger? will this approach work? I'm having issue since swagger is using http protocol..
-
aj go about 3 yearsI'm getting error in repairing IIS..its like looking for a file..
-
Dominic Isaia about 3 yearsThank you so much for this solution. This saved me a lot of headache.
-
Julian almost 3 yearsBut then you will use http instead of https after this step?
-
Julian about 2 yearsis this the same answer as from Bashar Abu Shamaa / Mar 22 2021 at 14:52? Please update that one!
-
Smitty-Werben-Jager-Manjenson about 2 yearsThis worked for me. Not sure how it got unchecked, but thank you!
-
Smitty-Werben-Jager-Manjenson about 2 yearsThis 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.