Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Xdebug Not Working with Windows 10, WSL and VS Code

See original GitHub issue

Describe the bug I just started using WP Local Docker, so thank you so much for developing such a great resource. Since I’m not super familiar with Linux and Docker, it’s taking me some time to get up to speed. The good news is that I’ve got most things configured at this point. The only item I can’t figure out is Xdebug.

When I try to run debugging using VS Code, breakpoints don’t work and I get this message in debug.log on every page load:

Xdebug: [Step Debug] Could not connect to debugging client. Tried: (from HTTP_X_FORWARDED_FOR HTTP header), host.docker.internal:9003 (fallback through xdebug.client_host/xdebug.client_port) :-(

I’ve used Xdebug a lot in the past, so I’m pretty confident I know how to use it generally, but I can’t seem to get it working with Windows 10, WSL and Docker. Can you give me any advice?

Thanks a ton.

Environment information

  • Device: Acer Laptop
  • OS: Windows 10 with WSL
  • Docker Desktop version: 4.5.1
  • Browser and version: Chrome v99.0.4844.51
  • WordPress version: 5.9.2

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:34 (5 by maintainers)

github_iconTop GitHub Comments

jg314commented, Nov 1, 2022

I was finally able to get Xdebug working with WSL 2, Docker and WP Local Docker. I followed very closely to the steps outlined at

Here are the steps I followed in case this will help someone else:

  1. Start Docker Desktop.
  2. Within the WSL 2 terminal enter this command to get the needed IP address: ip addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'
  3. Open the file at /config/php-fpm/docker-php-ext-xdebug.ini within the WP Local Docker website you’re working on. Set xdebug.client_host to be whatever IP address was returned in step 2. For example, the final line might look like xdebug.client_host = Until we can find a better solution, you’ll need to repeat steps 2 and 3 every time WSL 2 restarts.
  4. Run 10updocker stop all in the WSL 2 terminal.
  5. Run 10updocker start env-name in the WSL 2 terminal. Make sure to replace env-name with the name of your environment.
  6. If you get the error Xdebug: [Step Debug] Time-out connecting to debugging client... take a look at It’s likely Xdebug is running on every page load, even if VS Code isn’t debugging.

For what it’s worth @LoveDuckie, I didn’t need to change the Remote.WSL2: Connection Method setting in VS Code. It worked with the default wslExeProxy option for me.

Thanks again for the help @LoveDuckie and @nicholasio.

nicholasiocommented, Nov 2, 2022

FWIW: I think we would not have this problem if we were running the docker daemon inside WSL 2 directly instead of Docker Desktop.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Xdebug 3.0 WSL2 and VSCode - Configuration That Works
Xdebug did not work with this configuration—presumably because port 9003 was not being forwarded from Windows to WSL2.
Read more >
Debug PHP with VS Code and Windows Subsystem for Linux ...
In this video, I show how to set up XDebug with PHP in WSL ( Windows Subsystem for Linux) and use it with...
Read more >
VSCode & PHP XDebug from Localhost, WSL2 and Docker ...
If you are NOT running VSCode on the same host, which will be the case if you are running VSCode in WSL2 mode...
Read more >
Developing in WSL - Visual Studio Code
The Visual Studio Code WSL extension lets you use the Windows Subsystem for Linux (WSL) as your full-time development environment right from VS...
Read more >
Work in Windows Subsystem for Linux with Visual Studio Code
Windows Subsystem for Linux (WSL) is an optional feature on Windows 10. ... Note: If this command does not work, you may need...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found