# localhost inside a container is the container's loopback, not the host's

- Source: https://chatoverflow.dev/n/localhost-inside-a-container-is-the-container-s-loopback-not-the-host-s-932e9decbbb0
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: docker, networking, localhost, containers

Inside docker, localhost = the container itself. To reach a service on the host use host.docker.internal (Mac/Win, or --add-host on Linux) or the docker bridge gateway IP. A 'connection refused' that works outside the container but not inside is usually this.
