I had this working on another Drupal VM, but for some reason I can't get it to work anymore. I am trying to debug a Drush migration script and I have some breakpoints put in but it never stops at the breakpoints. I followed the steps shown here.

Here is my Xdebug section of config.yml from Vagrant:

# XDebug configuration. XDebug is disabled by default for better performance.
php_xdebug_default_enable: 1
php_xdebug_coverage_enable: 1
php_xdebug_cli_enable: 1
php_xdebug_remote_enable: 1
php_xdebug_remote_connect_back: 1
php_xdebug_remote_host: xxx.xxx.xx.xx // My Vagrant IP is really here.
# Use PHPSTORM for PHPStorm, sublime.xdebug for Sublime Text.
php_xdebug_idekey: PHPSTORM
php_xdebug_max_nesting_level: 256

The web server debug validation shows everything is good. I also verified that if I debug on a page that I visit from a browser, it stops at breaks points so it is for sure working.

Also, the PHP CLI does have Xdebug:

PHP 7.0.14-2+deb.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.14-2+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans

One thing I noticed, is that if I set Phpstorm to break at first line in PHP Script, I noticed the following notice in debugger: Can't compute source position. The script 'drush.phar' isn't associated with any text file type.

Here is the Xdebug log:

Log opened at 2017-03-24 02:21:50
I: Connecting to configured address/port:
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/mysite/web/drush.phar" language="PHP" xdebug:language_version="7.0.14-2+deb.sury.org~xenial+1" protocol_version="1.0" appid="12759" idekey="18466"><engine version="2.5.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2016 by Derick Rethans]]></copyright></init>

<- feature_set -i 1 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="show_hidden" success="1"></response>

<- feature_set -i 2 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_depth" success="1"></response>

<- feature_set -i 3 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="3" feature="max_children" success="1"></response>

<- status -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="4" status="starting" reason="ok"></response>

<- step_into -i 5
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="5" status="break" reason="ok"><xdebug:message filename="file:///var/www/mysite/web/drush.phar" lineno="8"></xdebug:message></response>

<- breakpoint_set -i 6 -t line -f file:///var/www/mysite/web/modules/contrib/migrate_tools/migrate_tools.drush.inc -n 226
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="6" id="127590001"></response>

<- breakpoint_set -i 7 -t line -f file:///var/www/mysite/web/core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php -n 22
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="7" id="127590002"></response>

<- breakpoint_set -i 8 -t line -f file:///var/www/mysite/web/core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php -n 56
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="8" id="127590003"></response>

<- breakpoint_set -i 9 -t line -f file:///var/www/mysite/web/core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php -n 37
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="9" id="127590004"></response>

<- stack_get -i 10
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="10"><stack where="{main}" level="0" type="file" filename="file:///var/www/mysite/web/drush.phar" lineno="8"></stack></response>

<- run -i 11
Log opened at 2017-03-24 02:21:51
I: Connecting to configured address/port: xxx.xxx.xx.xx:9000.
W: Creating socket for 'xxx.xxx.xx.xx:9000', poll success, but error: Operation now in progress (29).
E: Could not connect to client. :-(
Log closed at 2017-03-24 02:21:51

Any ideas on what I can try to get it to work?

Update - Things I have tried

  • Destroy vagrant machine and start over
  • Different combination of Xdebug settings in config.yml (Set to how it comes by default, removing remote_host, adding localhost, etc..)
  • Changing port to 9001 (both PHPStorm and Vagrant)

2 Answers 2


I just had this problem. It happened because I was using drush launcher (https://github.com/drush-ops/drush-launcher). This tool allows to type "drush" in your Drupal directory, instead of "./vendor/bin/drush", but it seems to confuse xdebug. Using "./vendor/bin/drush" fixed the problem.

  • This put me on the right path, I also had to set an environment variable in the container: export PHP_IDE_CONFIG="serverName=MyServer" where MyServer is the name of the server in Preferences / Languages & Frameworks / PHP / Servers where you do your path mapping
    – Darvanen
    Commented Jun 25, 2019 at 6:28
  • Specifically, drush-launcher unloads xdebug for speed purposes. See github.com/drush-ops/drush-launcher#xdebug-compatibility for an env variable which disables this behavior. Or just use vendor/bin/drush as this answer suggests. Commented Jun 6, 2020 at 15:49

Maybe this can help: Debugging PHP CLI scripts with PhpStorm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.