Xdebug Could not connect to debugging client

The following issue, originally detailed at Could not connect to debugging client for an older version of the Local app, is still happening on all sites. Other, similar threads in the forums don’t provide a solution. Modifying the php.ini to use port 9003 doesn’t work.


Issue Summary

In debug log, it is spamming this error message:

[05-Jun-2021 16:01:57 UTC] Xdebug: [Step Debug] Could not connect to debugging client. Tried: 127.0.0.1:9000 (from HTTP_X_FORWARDED_FOR HTTP header), localhost:9000 (fallback through xdebug.client_host/xdebug.client_port) :-(

[05-Jun-2021 16:01:58 UTC] Xdebug: [Step Debug] Could not connect to debugging client. Tried: 127.0.0.1:9000 (from HTTP_X_FORWARDED_FOR HTTP header), localhost:9000 (fallback through xdebug.client_host/xdebug.client_port) :-(

[05-Jun-2021 16:01:58 UTC] Xdebug: [Step Debug] Could not connect to debugging client. Tried: 127.0.0.1:9000 (from HTTP_X_FORWARDED_FOR HTTP header), localhost:9000 (fallback through xdebug.client_host/xdebug.client_port) :-(

Troubleshooting Questions

  • Does this happen for all sites in Local, or just one in particular?
    Yes.
  • Are you able to create a new, plain WordPress site in Local and access it in a Browser?
    Yes.

Replication

System Details

  • Which version of Local is being used?
    6.4.0+5927
  • What Operating System (OS) and OS version is being used?
    MacOS 12.4

I have seen the same thing on my Mac. I believe that I tracked it to being related to the xdebug.start_with_request setting in php.ini. To alleviate this I set that to xdebug.start_with_request=trigger, but this then requires that you manually trigger Xdebug when needed, so not an ideal solution. Even still, I am not 100% certain that this stops the log spamming all the time. Does anyone have a better fix, or do we need to wait on an update to Local to fix this?

This happens on Windows 10 too. It’s a PHP 8 issue. I was able to manually adjust the php.ini.hbs file as described by Afragen here and that did the trick: Update PHP 8 lighting service - please

I didn’t exactly solve the issue, but I’ve had to deactivate xdebug (by commenting out the appropriate lines in the php.ini.hbs file) because of considerable performance issues on all my local sites when it remains active.

Anyone have a solution that doesn’t involve outright disabling it and is PHP8 compatible?