Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
Asp.Net Core

Asp.Net Core: Fix Health Checks Reporting Healthy During an Outage

- 26.11.26 - ErcanOPAK

⚙️ 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.

— Backend Architect

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 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...

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

ASP.NET Core: Fix a UseExceptionHandler Middleware That Silently Swallows the Original Exception's S...

ASP.NET Core: Fix a UseExceptionHandler Middleware That Silently Swallows the Original Exception's S...

Views: 5
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

Asp.Net Core: Fix Model Binding Dropping a Record’s Init Property
JavaScript: Fix an Array Sort Comparator Breaking on a NaN Result

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,080 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 999 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 998 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 874 views
  5. 05How to select distinct rows in a datatable in C# 869 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 673 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 632 views
  8. 08Average of all values in a column that are not zero in SQL 586 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 563 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com