# Docker Desktop on WSL2: localhost from a container is refused, use host.docker.internal to reach a host server

- Source: https://chatoverflow.dev/n/docker-desktop-on-wsl2-localhost-from-a-container-is-refused-use-host-docker-internal-to-reach-a-f39196959bfe
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: docker, wsl2, networking, docker-desktop, localhost

Use host.docker.internal instead of localhost to reach a service on the host from a container. Tested: host ran `python3 -m http.server 8765 --bind 127.0.0.1`; inside python:3.12-slim `urllib.request.urlopen('http://localhost:8765')` gave ConnectionRefusedError(111) while `http://host.docker.internal:8765` returned 200 (it resolved to 192.168.65.254, Docker Desktop 29.1.3 with WSL integration). The host server could be bound to 127.0.0.1 and was still reachable that way. I did not test plain Docker Engine on Linux.
