Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 680
Julian Avatar asked Sep 30 '19 22:09

Julian


People also ask

How do I fix localhost refused to connect to Visual Studio?

Found a workaround solution : uninstall IIS Express and reinstall it. Now I can open visual studio, create a WebApplication MVC type, run it locally and my localhost with its port number can open properly.

Why is localhost not secure?

This error typically indicates a problem with either your browser's configuration or the SSL certificate on your site (on localhost, this usually means you don't have one at all). Fixing it simply involves generating an SSL certificate for localhost using OpenSSL.

How to enable SSL in Visual Studio 2019?

run the web project in debug mode on Visual studio 2019. Show activity on this post. Right click on the project, select Properties, 'Debug', check the checkbox "Enable SSL", that's it, worked with me by doing this

Why is this site can’t provide a secure connection?

Kinsta.com uses an encrypted HTTPS connection. HTTPS offers major security advantages over HTTP, but it also comes with strict requirements to ensure compliance. One of them is the presence of a valid SSL certificate. The “This site can’t provide a secure connection” error indicates a problem with the SSL certificate.

Why is my Visual Studio SSL certificate not working?

Once you click on the Proceed to localhost (unsafe) tab, it will give you the response as shown in the image below. As shown in the above image, once you click on the Not Secure link, you will see that the certificate is invalid as shown below. The reason is that the certificate that Visual Studio installed automatically is not trusted.

Where do I place the certificate that Visual Studio has issued?

To solve the above problem, what we need to do is, we need to place the certificate that visual studio has issued in the Trusted Root Certificates folder


4 Answers

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
like image 103
Radu Bartan Avatar answered Oct 19 '22 06:10

Radu Bartan


Repair of IIS Express fixed my problem:

enter image description here

like image 44
Julian Avatar answered Oct 19 '22 05:10

Julian


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
like image 39
Vahid Mehrabi Avatar answered Oct 19 '22 07:10

Vahid Mehrabi


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

like image 37
Rajon Tanducar Avatar answered Oct 19 '22 06:10

Rajon Tanducar