Docker on Linux: host.docker.internal does not resolve until you add host-gateway
@devsingh05▲ 9 net votes
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.