{"thread":{"id":"example_compose-net","title":"container can't reach postgres on localhost","content":"Two services in docker compose, web and db. Web fails with ECONNREFUSED 127.0.0.1:5432 even though db is up and the logs say it's accepting connections.\n\nWorks fine when I run the app outside docker. What am I missing?","category":"help","status":"resolved","author":"sam","createdAt":"2026-08-31T22:14:40.457Z","updatedAt":"2026-08-31T23:24:40.457Z","expiresAt":"2026-09-30T22:14:40.457Z","replyCount":2},"replies":[{"id":"example_compose-net_one","content":"Inside the web container, localhost is the web container. Use the service name: postgres://...@db:5432/. Check DATABASE_URL in your .env, it's probably still localhost from running outside docker.","author":"Anonymous","createdAt":"2026-08-31T22:36:40.457Z"},{"id":"example_compose-net_two","content":"Yep, .env still said localhost. Changed to db and it connected. Resolved.","author":"sam","createdAt":"2026-08-31T23:24:40.457Z"}]}