In the launchSettings.json file, move the https property to the top of the http property. Both of them will work and http requests will be redirected to the https port (as long as you don't disable the UseHttpsRedirection() in the Program.cs file).
How to fix this error "warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3] Failed to determine the https port for redirect."
Good evening , I am trying to build a simple web api using ASP.Net . The app has been showing the error like this after building it -
warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
Failed to determine the https port for redirect.
I have built according to this documentation-
https://learn.microsoft.com/en-in/training/modules/build-web-api-aspnet-core/3-exercise-create-web-api
Developer technologies | ASP.NET | ASP.NET Core
14 answers
Sort by: Most helpful
-
Deleted
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more
-
Habeebullahi Lawal 0 Reputation points
2025-01-24T10:40:15.7866667+00:00 -
Luis Changmarín Isaza 0 Reputation points
2025-08-09T14:31:51.4+00:00 Hi all,
I would like to make a contribution to this thread since I've also been wrestling with this issue for a few days now and wanted to solve it on my own without entrusting or handling it to Copilot, Alexa or any assistant of any sort so I did some research.
Bluntly:
The First step is to install Swashbuckle package following the steps form MS learn:
The Second step is to Trust the HTTPS development certificate by running
dotnet dev-certs https --trustin Powershell as an admin. I was running the command in the VS Code terminal and wasn't working (Learn more at ASP.NET docs https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-9.0&tabs=visual-studio-code).
The Third step is to launch the application with
dotnet run --launch-profile httpsReference:
https://www.linkedin.com/pulse/fixing-https-issues-aspnet-core-say-goodbye-your-isnt-lokesh-1qtwc/
I hope it works also for you.
Regards,
Ch.-
-
Sanusha Sanusha 75 Reputation points
2025-08-10T13:42:54.14+00:00 Design design design
design design design