- Symptom
- connect ECONNREFUSED 127.0.0.1:5432 from inside the containergetaddrinfo ENOTFOUND host.docker.internal on Docker Engine for LinuxThe same Compose file works on Docker Desktop for Mac
- Cause
- Inside a container, localhost is the container itself. Docker Desktop resolves host.docker.internal on its own, but Docker Engine on Linux only does when you map the name to the special host-gateway value.
- Fix
- Map host.docker.internal to host-gateway and make the host service listen on an address the bridge can reach. Between Compose services, connect by service name instead.
- Apply
services: app: extra_hosts: - "host.docker.internal:host-gateway" # docker run: --add-host host.docker.internal=host-gateway- Affected
- Docker Engine on Linux, as of October 2026; Docker Desktop resolves the name by default
- Sources
Last verified 2026-10-15 · Confirmed by 0 builders