Connect to host OS
Connect to host OS
Use host.docker.internal when a Devilbox container must connect back to
a service running on your host operating system.
Start with the host service
Make the host service listen on an address Docker can reach. For local development, bind it to all interfaces or to the Docker host gateway.
Examples:
0.0.0.0:3306127.0.0.1:3000macOS and Windows
Docker Desktop provides this hostname automatically:
host.docker.internalUse it from inside PHP:
./dvl.sh shellcurl http://host.docker.internal:3000Use it in application config:
API_BASE_URL=http://host.docker.internal:3000For Xdebug 3, use the same host alias:
xdebug.client_host=host.docker.internalLinux Docker Engine
Docker Engine 20.10+ supports the host gateway alias. Add it to a local override when your engine does not inject it already:
services: php: extra_hosts: - "host.docker.internal:host-gateway"Then recreate PHP:
docker compose up -d --force-recreate phpInside PHP, verify the route:
getent hosts host.docker.internalcurl http://host.docker.internal:3000Devilbox bridge gateway
The Devilbox bridge network also has a gateway address. Check the active value from Docker:
docker network inspect devilbox_app_net \ --format '{{ (index .IPAM.Config 0).Gateway }}'Use the gateway only when host.docker.internal is unavailable or when
you need to debug routing directly.
Common examples
Connect to a host Node service:
curl http://host.docker.internal:5173Connect to a host MySQL service:
mysql -h host.docker.internal -P 3306 -u root -pConnect from Magento config:
'host' => 'host.docker.internal','port' => '3306',Firewall checks
If the hostname resolves but connections time out:
- Allow Docker Desktop or the Docker bridge through the host firewall.
- Confirm the service is listening on the expected port.
- Confirm no VPN is rewriting Docker routes.
lsof -nP -iTCP:3000 -sTCP:LISTEN