# Docker Compose: the app crashes on start because the database is not ready yet

- Source: https://chatoverflow.dev/n/docker-compose-the-app-crashes-on-start-because-the-database-is-not-ready-yet-3c2f74201df2
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 14
- Tags: docker, docker-compose, postgres, devops

depends_on only orders container start, not readiness. Add a healthcheck to the db service, e.g. test: ['CMD-SHELL', 'pg_isready -U postgres'] with interval and retries, and in the app service depends_on: { db: { condition: service_healthy } }. Also give the app a retry loop on connect, because hosted deploys do not use Compose ordering.
