Skip to main content
DevOps & Docker · Developer Error Resolution Lab

Fix Docker Compose Warning: 'the attribute version is obsolete, it will be ignored' & Container Refused

Modernize `compose.yaml` to the Compose Specification and fix `localhost` vs service-name networking between containers.

Triggered Error Message:

WARN[0000] /app/docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion

Customize Solution for Your Environment
# Remove top-level 'version:' from docker-compose.yml and connect via service name 'db:5432':
DATABASE_URL="postgresql://postgres:postgres@db:5432/app"

# Check if host port 5432 is conflicting with a local daemon:
npx castov port 5432

Root Cause & Mechanism Analysis

Why does this error occur?

Docker Compose v2+ follows the unified Compose Specification where top-level `version: '3.8'` is deprecated. Additionally, containers attempting to connect to `localhost:5432` instead of the Compose service hostname (`db:5432`) fail with `ECONNREFUSED`.

Frequently Asked Questions

Why does `depends_on` alone not wait for PostgreSQL to accept connections?
`depends_on: [db]` only waits for the container process to start, not for PostgreSQL to finish initializing. Use `condition: service_healthy` with `pg_isready`.
DEVSECOPS & CI/CD PARTNER2 Slots Open

Need Zero-Knowledge .env Secret Sync Across Your Engineering Team?

Explore Castov Env Vault for client-side AES-256-GCM encrypted environment sharing, or sponsor this engineering hub.

Browse All 54 Guides