`$ dotnet run` won't serve https with .Net Core 3.0 on OS X
See original GitHub issueSymptoms:
I have a .Net Core 3.0 app that I’m unable to load in a browser ONLY when running it using the Mac OS X CLI, like so:
$ dotnet new webapp
$ dotnet run
watch : Started
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using '/Users/<user>/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
info: Microsoft.Hosting.Lifetime[0]
Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: /Users/<user>/Sandbox/coreapp3test
So everything looks good at this point, except when opening the URL in a browser I receive:
This site cannot be reached
localhost unexpectedly closed the connection.
Core Issue:
This has something to do with HTTPS protocol. Navigating to http://localhost:5000
does render an https redirect. So the server is actually listening…
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 GET http://localhost:5000/
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 9.6705ms 307
Furthermore, removing the app.UseHttpsRedirection();
from the Configure
method of startup.cs
and then navigating to http://localhost:5000
renders the page correctly, while https://localhost:5001
still fails
Notes:
- I can run the app in VS Code, so the runtime must be installed correctly
- .NET Core 2.2 apps work fine with the CLI - I can run them from the CLI without issue. So it appears isolated to 3.0
- The Windows CLI appears to work without issue
- I’ve also tried the following, without success:
- Removing
bin/
andobj/
and restoring / building again - Re-installing the SDK - same result
- Disabling firewall (in case that was blocking the connection)
- Generating multiple web project types (e.g. angular, mvc, etc.) to see if it was related to the template
- Removing
System Info:
$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.0.100
Commit: 04339c3a26
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.14
OS Platform: Darwin
RID: osx.10.14-x64
Base Path: /usr/local/share/dotnet/sdk/3.0.100/
Host (useful for support):
Version: 3.0.0
Commit: 7d57652f33
.NET Core SDKs installed:
3.0.100 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Unable to configure HTTPS endpoint. No server certificate ...
I'm on a Mac (macOS 12.6.7) trying to run a ASP.NET Core website project in VS Code, and none of the above answers...
Read more >Configuring HTTPS in ASP.NET Core across different ...
In this blog post we're going to go through how to setup an ASP.NET Core app with HTTPS for local development on Windows,...
Read more >Enforce HTTPS in ASP.NET Core
Close any browser instances open. Open a new browser window to app. See HTTPS Error using IIS Express (dotnet/AspNetCore #16892) for ...
Read more >Why doesn't my ASP.NET Core 7 web app launch on ...
In .NET 7, the ASP.NET team decided to change the launch settings so that the default behaviour on executing dotnet run (or dotnet...
Read more >Cannot debug net6.0-macos Apps - Developer Community
When I hit debug, the following error is shown in the Terminal: Possible reasons for this include: * You misspelled a built-in dotnet...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
not work for me with 3.1 and osx 13.5.3
Hi, I am having the same issue. Work perfect when debugging in VS for Mac, but in terminal with dotnet run I get the ssl error
.NET Core SDK (reflecting any global.json): Version: 3.0.101 Commit: bc5f8df0f5
Runtime Environment: OS Name: Mac OS X OS Version: 10.15 OS Platform: Darwin RID: osx.10.15-x64 Base Path: /usr/local/share/dotnet/sdk/3.0.101/
Host (useful for support): Version: 3.0.1 Commit: 32085cbc72
.NET Core SDKs installed: 2.1.202 [/usr/local/share/dotnet/sdk] 2.1.505 [/usr/local/share/dotnet/sdk] 2.1.701 [/usr/local/share/dotnet/sdk] 2.2.106 [/usr/local/share/dotnet/sdk] 2.2.107 [/usr/local/share/dotnet/sdk] 2.2.300 [/usr/local/share/dotnet/sdk] 3.0.100 [/usr/local/share/dotnet/sdk] 3.0.101 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.12 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.12 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.12 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download