/up healthcheck passes while the database is unreachable #165

Closed
opened 2026-09-26 08:53:06 +02:00 by myrmidex · 1 comment
Owner

The container healthcheck reported healthy for 37 hours while every authenticated page returned HTTP 500, because the database container was absent (see #164).

Dockerfile:70 runs curl -f http://localhost:8000/up, and bootstrap/app.php:16 configures health: '/up'. Laravel's built-in health endpoint dispatches DiagnosingHealth and returns 200 without touching the database, so a missing DB reads as a healthy app.

The result is a silent outage: no alert, no restart, no signal of any kind. The failure was found by loading a page by hand.

Fix

Register a DiagnosingHealth listener that verifies DB connectivity (e.g. DB::connection()->getPdo()), so /up fails when the database is unreachable and the healthcheck turns the container unhealthy.

Note

A separate /health route exists at routes/web.php:44 returning a static {"status":"ok"}. It is not what the healthcheck uses. Worth deciding whether to converge or remove it.

Tests

  • Feature test asserting /up returns non-200 when the DB connection throws
  • Feature test asserting /up returns 200 when healthy
The container healthcheck reported `healthy` for 37 hours while every authenticated page returned HTTP 500, because the database container was absent (see #164). `Dockerfile:70` runs `curl -f http://localhost:8000/up`, and `bootstrap/app.php:16` configures `health: '/up'`. Laravel's built-in health endpoint dispatches `DiagnosingHealth` and returns 200 without touching the database, so a missing DB reads as a healthy app. The result is a silent outage: no alert, no restart, no signal of any kind. The failure was found by loading a page by hand. ## Fix Register a `DiagnosingHealth` listener that verifies DB connectivity (e.g. `DB::connection()->getPdo()`), so `/up` fails when the database is unreachable and the healthcheck turns the container unhealthy. ## Note A separate `/health` route exists at `routes/web.php:44` returning a static `{"status":"ok"}`. It is not what the healthcheck uses. Worth deciding whether to converge or remove it. ## Tests - Feature test asserting `/up` returns non-200 when the DB connection throws - Feature test asserting `/up` returns 200 when healthy
myrmidex added this to the v1.4.3 milestone 2026-09-26 08:53:06 +02:00
myrmidex added the
bug
label 2026-09-26 08:53:06 +02:00
myrmidex self-assigned this 2026-09-26 08:53:06 +02:00
Author
Owner

Superseded by #164, which now covers the healthcheck fix along with the exception-logging fallback and the startup/Horizon supervision defects from the same incident. Consolidating to keep the work in one ticket.

Superseded by #164, which now covers the healthcheck fix along with the exception-logging fallback and the startup/Horizon supervision defects from the same incident. Consolidating to keep the work in one ticket.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lvl0/fedi-feed-router#165
No description provided.