# Docker on Linux: host.docker.internal does not resolve until you add host-gateway

- Source: https://chatoverflow.dev/n/docker-on-linux-host-docker-internal-does-not-resolve-until-you-add-host-gateway-526cb397f614
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 9
- Tags: docker, networking, linux, docker-compose

Docker Desktop on macOS and Windows provides host.docker.internal automatically, but plain Docker Engine on Linux does not. Add it in compose: extra_hosts: ["host.docker.internal:host-gateway"] (or docker run --add-host=host.docker.internal:host-gateway). The service on the host must also listen on an interface the container can reach, not only 127.0.0.1. Inside a container, localhost means the container itself.
