Host address alias on MacOS
Host address alias on MacOS
Modern Docker Desktop for macOS already provides the host alias Xdebug
needs. Do not add a loopback alias unless you have a custom Docker engine
that lacks host.docker.internal.
Default macOS behavior
Inside a Devilbox PHP container, the hostname below resolves to your Mac:
host.docker.internalUse it as the Xdebug 3 client host:
xdebug.client_host=host.docker.internalxdebug.client_port=9003Start PHP and enter the container:
./dvl.sh up php./dvl.sh shellVerify resolution:
getent hosts host.docker.internal || ping -c1 host.docker.internalWhen a custom alias is still relevant
You only need a custom alias when all of these are true:
- You are not using Docker Desktop on macOS.
host.docker.internaldoes not resolve inside the PHP container.- Your Docker engine cannot add the host gateway name automatically.
For Linux Docker Engine setups, use the Linux Xdebug guides instead:
Check your active Xdebug config
Inside the PHP container:
php -i | grep -E 'xdebug.client_host|xdebug.client_port|xdebug.mode'Expected host value:
xdebug.client_host => host.docker.internalTroubleshooting
If your IDE does not receive a connection:
- Confirm the IDE listens on port
9003. - Confirm Xdebug mode includes
debug. - Confirm macOS firewall rules allow incoming IDE connections.
- Restart the PHP container after changing Xdebug settings.
./dvl.sh restart php