Back to KB
Difficulty
Intermediate
Read Time
4 min

Your Next.js health check is lying to you (and how to fix it)

By Codcompass Team··4 min read

Current Situation Analysis

The most common failure pattern in indie SaaS production environments is the "useless 200" health check. Applications return 500 Internal Server Error to customers, Stripe webhooks fail silently, and background queues stall, yet GET /api/health consistently returns 200 OK. This occurs because traditional health checks only verify process liveness (return { ok: true }), which provides the cheapest possible signal: the runtime is alive.

This shallow approach fails to detect critical failure modes:

  • Environment Drift: Mismatched or renamed environment variables (e.g., DATABASE_URL vs DATABASE_POOL_URL) between CI/staging and production.
  • Dependency Exhaustion: Connection pool saturation, expired service-role tokens, or auth provider outages.
  • Routing/Middleware Breakage: Unintended 308 redirects or silent event swallowing in webhook handlers.
  • Platform Blind Spots: Internal liveness probes (Vercel, Kubernetes) only verify pod reachability. They cannot detect DNS expiration, TLS renewal failures, CDN edge degradation, BGP routing issues, or third-party API degradation.

Without testing actual dependency roundtrips and aligning HTTP status codes with monitoring expectations, platforms continue routing traffic to broken instances until customers report failures—the worst possible detection mechanism.

WOW Moment: Key Findings

Implementing a Layer 2 (dependency-aware) health check dramatically reduces mean time to detection (MTTD) and eliminates false health signals caused by caching or runtime mismatches. The sweet spot for indie projects balances detection accuracy with minimal overhead.

| Approach | Detection Latency | False Positive Rate | Query Overhead | D

🎉 Mid-Year Sale — Unlock Full Article

Base plan from just $4.99/mo or $49/yr

Sign in to read the full article and unlock all 635+ tutorials.

Sign In / Register — Start Free Trial

7-day free trial · Cancel anytime · 30-day money-back