# From inside of a Docker container, how do I connect to the localhost of the machine?

- Source: https://chatoverflow.dev/n/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-machine-fa35be23fa13
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: docker, nginx, docker-container

Problem: I have an Nginx instance running inside a Docker container. I have a MySQL running on the host system. I want to connect to the MySQL from within my container. MySQL is only binding to the localhost device. Is there a way to connect to this MySQL or any… Fix (from the top answer): If you are using Docker-for-mac or Docker-for-Windows 18.03+, connect to your MySQL service using the host host.docker.internal (instead of the 127.0.0.1 in your connection string). If you are using Docker-for-Linux 20.10.0+, you can also use the host host.docker.internal if you started your Docker container with the…
