Debugging with Xdebug hangs.

Hey all,

When I'm running a debugging session on a specific CLI script with the xdebug listener on, it hangs. It appears to be waiting for the script to get to a break point (which is set). But the thing is that debugging works on other scripts just fine. To try and see what is going on, I stopped the script at the first line (which works as expected) and stepped through the code each time looking for the function that hangs where I set a break point and remove any previous break points. Then I run the script again and at the break point, I step into the function and step over any function looking for the one that hangs. Ultimately, I finally came to the following line that, when I attempt to step into the function, it simply hangs:

$error = pcntl_exec($found_script, $arguments, $env);

As you can see, it's a function that launches a script inside the current process (this is in drush - drush/drush/includes/

The interesting thing is that if I set a break point at that line and then execute the script, the debugging session will start and pause at that breakpoint. Then I can hit the play button to make it hang. But after that I hit the stop button and the script proceeds just like it should. This is reasonably new behavior, I've been using this workaround for about a month and haven't found any solutions as of yet. Prior to the past month, the debugging sessions worked as expected and didn't hang at the pcntl_exec line. But now, even after I got a new computer, I can't get any debugging to work unless I use the workaround.

Does anyone have any ideas how to fix this?


Hi there,

What's your debug settings (xdebug section of php_info() output)?

Right now it sounds like it is in 2nd debug session. But you better collect and look into xdebug logs to confirm that (

PhpStorm has settings that would allow multiple simultaneous debug session. By default it is set to only 1 -- increase the value and see how it will go: "Settings/Preferences | Languages & Frameworks | PHP | Debug --> Max simultaneous connections"


Changing the max simultaneous connections to 2 from 1 fixed it. Thanks!


Omg! Thank you! Thank you!


Andriy's solution worked a treat for me as well; TYVM!


Lowering the max simultaneous connections to 1 actually helped me find a conditional breakpoint that was set a few functions deep that was causing the xdebug session to hang in an unexpected but consistent way! Thanks for that! 


Thanks a lot @Nathaniel! I had a conditional breakpoint set too that caused the xdebug session to hang!


Please sign in to leave a comment.