Docker Phpstorm Xdebug

Posted : admin On 1/2/2022


I’m a bit confused using xdebug, docker for windows, and phpstorm…

i have xdebug configured in a container with PHP.
Here is what appears in my php.ini from within this container :

PHPSTORM + XDEBUG (2/3) + WSL2 + DOCKER. Small example project to show how to configure xdebug (2 or 3) with WSL2 and Docker. This solution works only if you use PhpStorm on WSL2 with X server! WSL2 change Linux IP every reboot time, so you should, add global variable (WSLIP) in your Linux system. This is to test if you can connect from Docker image to the xdebug listener in IDE - to confirm that it's not a firewall issue - be it your ESET or Docker one. Obviously, it means that 'phone handle' icon in PhpStorm must be activated or IDE is already listening for incoming xdebug connections.

from this container i can’t access directly my Windows host IP, but i can access two IPs :
the docker host IP which is
and the docker IP i have from Windows (resolving docker) which is
why is there so many IPs ? what are there referring to exactly ?
i even can ping which might be some virtual bridge of some kind ?

Docker Phpstorm Xdebug

xdebug communicates on port 9000. i have bind port 9000 to 9000 for this container :

from my understanding this binds port 9000 from this container to port 9000 on (docker from windows) ?
then what IP should i use for xdebug.remote_host ?
by default PHPStorm waits for some connection on port 9000, on local machine (Windows).
should I set what it calls a DBGp Proxy ? Pointing to docker ? On port 9000 ?

for now i have tried xdebug.remote_host with , or localhost and could not get it to work yet.

XDebug 3 only started working out of the box with PhpStorm version 2020.3

Reference article - Configure Xdebug

The list of changes from XDebug 2 to 3 are available here for reference - Upgrade Guide

Configuring PhpStorm

Phpstorm Xdebug Ssh

Go to PhpStorm -> Settings -> Languages & Frameworks -> PHP -> Servers

  1. Click '+'
  2. Name docker-cli (Same as serverName under PHP_IDE_CONFIG environment variable)
  3. Host _
  4. Default 80
  5. Debugger Xdebug
  6. Check the checkbox next to 'Use path mappings'
  7. Modify the absolute path on the server to /var/www/html

Phpstorm Docker Compose

Running the CLI Command

Docker Phpstorm Xdebug Nginx

  1. Add breakpoints file
  2. In PhpStorm click the icon to 'Start Listening for PHP Debug connections'
  3. Run in the docker file - docker-compose run php-container php test.php

Docker Phpstorm Xdebug


Phpstorm Docker Xdebug Not Working

  1. Check firewall or selinux if on linux
  2. The configuration host.docker.internal only became available under Mac and Windows with Docker version 20.04