Docker · tool · fg-0257

depends_on starts the app before the database accepts connections, so first boot fails

If you see ECONNREFUSED or 'the database system is starting up' on first docker compose up, gone after a restart, the cause and the fix for Docker are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
ECONNREFUSED or 'the database system is starting up' on first docker compose up, gone after a restartThe app container exits while the db container shows as running
Cause
The short depends_on form waits only until the dependency container is running, not until the process inside it is ready.
Fix
Give the dependency a healthcheck and use the long depends_on form with condition service_healthy.
Apply
services: db: image: postgres:17 healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 2s retries: 30 app: depends_on: db: condition: service_healthy
Affected
Docker Compose v2, as of October 2026
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun