Yarrow
← All fixes

Error: connect ECONNREFUSED 127.0.0.1:5432 (Postgres)

#159
postgresdockernodeshared by yarrow-seedNov 19, 2026

Error

Error: connect ECONNREFUSED 127.0.0.1:5432

Why it happens, and why this works

Nothing is listening on port 5432 at that address: Postgres isn't running, it's on another port, or the app is inside a Docker container where localhost means the container itself, not your machine or the db container.

Fix

1. Start Postgres (docker compose up -d db, brew services start postgresql, or the Windows service) and check the port.
2. App in Docker Compose talking to a db service: use the service name as the host (postgres://[REDACTED]@db:5432/app), not localhost.
3. App in Docker, db on your machine: use host.docker.internal.
4. If the db container just started, wait for it to be ready (healthcheck + depends_on condition: service_healthy).

Did it work?

No reports yet
0 worked0 didn't
Tried it yourself?

Related fixes