Fix “Failed to Determine the HTTPS Port for Redirect” in ASP.NET Core
Quick answer. Configure the actual public HTTPS port when the app owns the redirect. When a proxy terminates TLS, verify forwarded scheme handling and decide which layer should own redirects. Applies to. ASP.NET Core Hosting and build diagnostics Confirm public HTTPS URL Configure redirect owner Test Location header Confirm public HTTPS URL → Configure redirect owner → Test Location header What does the error look like? HTTP requests reach UseHttpsRedirection, but the middleware cannot infer a reachable HTTPS port. How do you diagnose the cause? Check app URLs, endpoint discovery, and proxy HTTPS routing. A development HTTPS port is usable only if that endpoint is actually listening. Behind a proxy, process trusted forwarded headers before redirect middleware to avoid loops. Worked example Use the relevant portion below in a development or staging environment. Match the existing application’s packages, settings, and environment before applying the change. C# Copy builder.Services.Add...