Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

906
Views
Xdebug: Could not connect to debugging client (Phpstorm + WSL2)

I am trying to convert my recent XAMPP development setup to a LAMP stack based on WSL2.

So far I've been successful. I can access my testpage test.php containing <?php phpinfo(); via https://localhost/test.php (using a self-signed certificate for dev-purposes.)

Sadly, I'm completely stuck at getting Xdebug to work.

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

I have been going through these threads already, but to no avail:

  • First
  • Second
  • Third

My setup:

  • Windows 10 with WSL2 installed
  • Ubuntu 20.04 with Apache2
  • PHP 8.0.5 with Xdebug 3.0.4
  • PhpStorm (IDE)

My Xdebug settings at /etc/php/8.0/apache2/php.ini:

[xdebug]
xdebug.mode=debug
xdebug.remote_port=9003
xdebug.client_port=9003
xdebug.start_with_request=yes
xdebug.remote_host=localhost
xdebug.idekey=PHPSTORM
xdebug.discover_client_host=1

;xdebug.client_host=localhost
;xdebug.remote_enable=1
;xdebug.remote_handler=dbgp

I have tried commenting "discover_client" and explicitly setting the client host to localhost. No change.

The output of phpinfo() seems to indicate that these settings are not ignored. See screenshot of the relevant parts.

The relevant settings for the virtual host in /etc/apache2/sites-available/default-ssl.conf are:

<VirtualHost: *:443>
    ServerName localhost
    DocumentRoot "/mnt/d/projects/testproject/public"
    <Directory "/mnt/d/projects/testproject/public/">
        Options +Indexes +Includes +FollowSymlinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

(The "all granted" is only temporary while debugging)

I don't know if this is relevant, but I made sure that C:\Windows\System32\drivers\etc\hosts contains

127.0.0.1 localhost
::1 localhost

So when I run

php -dxdebug.mode=debug /mnt/d/projects/testproject/public/test.php

I get

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

Does anyone see the problem? Or can anyone give me a hint on where to look next?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The option xdebug.start_with_request = yes tells Xdebug to try to debug every single request/script. If Xdebug fails to connect to the debug client (it takes values from xdebug.client_host and xdebug.client_port, or autodetected host if xdebug.discover_client_host is enabled) then it notifies you about that.

Normally such a messages will be written to the standard PHP's error log. Looks like you don't have it configured at all in your php.ini (as this is how it comes by default), therefore PHP sends it to your standard output instead.

If you want to prevent it from appearing on you terminal output you have to point the PHP error_log to a valid location.

Example of how I solved it in my case:

1- Edit your ini file:

sudo vi /etc/php/7.4/cli/php.ini

2- And add this line:

error_log = /var/www/log/php_error.log

NOTE: Change the previous routes to any valid directory you want.

3- Try again and the warning should disappear and now goes to the log file.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!