⚙️ Asp.Net Core: Fix Health Checks Reporting Healthy During an Outage
A default AddHealthChecks() setup only ever reports on what the checks you actually registered measure – a bare /health endpoint wired to nothing but the framework’s own process-liveness check says nothing about whether the database, a downstream API, or a message queue the app actually depends on is reachable, unless a specific health check was registered for each dependency individually. A deployment can pass every configured check and get marked Healthy by a load balancer or orchestrator while a dependency the app absolutely needs is completely down, simply because nobody ever registered a check that would have noticed.
🔎 The Problem
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHealthChecks(); // no AddCheck for SQL, Redis, etc.
var app = builder.Build();
app.MapHealthChecks("/health");
// Database connection refused -> every real request returns 500
// GET /health -> still 200 Healthy, because nothing was ever
// registered to actually probe the database
✅ The Fix
- Register an explicit health check (AddDbContextCheck, a database-specific package, or a custom IHealthCheck) for every hard dependency the app cannot function without, not just the process-liveness default, so a down dependency actually flips the reported status.
- Separate liveness (is the process itself alive, used for restart decisions) from readiness (are its dependencies currently reachable, used for routing traffic) with tagged health check groups, since conflating the two can make an orchestrator restart a perfectly healthy process pointlessly, or keep routing traffic to one that can’t serve it.
- Periodically test the health endpoint’s actual behavior by deliberately breaking a dependency in staging (stopping the database, blocking the downstream API) and confirming the endpoint reports Unhealthy, rather than assuming a configured check works just because it’s present in code.
🚨 Why This Is Dangerous
A load balancer or Kubernetes readiness probe trusting a health endpoint that never checks real dependencies will keep routing user traffic to an instance that can’t actually serve it, turning what should be an automatic failover into a user-facing outage with no automated mitigation ever kicking in.
A health check only reports on what you told it to check – an endpoint that always says Healthy might just mean nobody ever asked it about the thing that broke.
Related posts:

ASP.NET Core: Fix a Strongly-Typed Options Class Never Picking Up a Changed appsettings.json Value B...

ASP.NET Core: Fix a Request That Keeps Running After the Client Disconnects Because the Action Never...




