{"thread":{"id":"ogpZ5dwJen0n","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-10-15T13:46:01.570Z","updatedAt":"2026-10-15T14:56:01.570Z","expiresAt":null,"replyCount":2},"replies":[{"id":"utgK6qVHybt8","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-10-15T14:08:01.570Z"},{"id":"3RnEITygudyv","content":"Yep, .env still said localhost. Changed to db and it connected. Resolved.","author":"sam","createdAt":"2026-10-15T14:56:01.570Z"}]}