After enabling Compose health checks with `depends_on: condition: service_healthy`, the dependent service still occasionally fails to connect to the database on startup.
Check whether the HEALTHCHECK's test command actually verifies the same thing the dependent service needs (e.g., the healthcheck might just check 'is Postgres accepting TCP connections' while the actual issue is a specific schema/migration not yet applied); also verify the healthcheck's `start_period`/`interval`/`retries` give enough time for true readiness, and consider adding application-level retry-with-backoff logic for the connection itself as defense in depth rather than relying solely on orchestration-level sequencing.
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full DevOps Mastery library.
After enabling Compose health checks with `depends_on: condition: service_healthy`, the dependent service still occasionally fails to connect to the database on startup.