Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

907
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda