skip to Main Content

I’m having an issue with Xdebug in my local PHP setup. Here’s the situation:

I have Xdebug configured and it’s working fine when my IDE (PhpStorm) is set to "Start Listening for PHP Debug Connections". However, I don’t always have my IDE listening. When it’s not listening, I encounter errors with any PHP command, such as php artisan migrate, and the error looks something like this:

Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :

This problem doesn’t occur when my IDE is listening, but then I face another issue: every PHP command (like php artisan) stops at the debugger, and I have to click "Continue" in PhpStorm to proceed.

I would like to avoid having to start and stop the Xdebug listener in PhpStorm or deal with these interruptions. Is there a way to configure to ignore this error when the IDE isn’t listening?

Any help or suggestions would be greatly appreciated!

2

Answers


  1. There are several ways to start XDEBUG and you have probably forced it to start by using the xdebug.start_with_request=yes directive in your php.ini file.

    Set it to trigger as specified in the official documentation and add the relevant parameter to your querystring (i.e. ?XDEBUG_SESSION) when calling your page.

    Login or Signup to reply.
  2. This error message is sent to stderr when you enable some level of error logging and Xdebug doesn’t have access to a file path it’s able to write. If you disable logging, it should go away:

    xdebug.log_level=0
    

    If you want to use logging, make sure your PHP process has write permission for log file:

    xdebug.log_level=1
    xdebug.log=/tmp/xdebug.log
    

    You may also want to lower timeout directive to speed up things when not debugging (according to tool author, Xdebug doesn’t wait if there’s no IDE listening, but in practice it isn’t always the case):

    xdebug.connect_timeout_ms=20
    

    … or even make it opt-in:

    xdebug.start_with_request=trigger
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search