Opened 4 months ago
Last modified 4 days ago
#63979 reopened defect (bug)
WordPress Core setup does not configure XDebug properly
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.9.1 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Build/Test Tools | Keywords: | commit fixed-major dev-feedback |
| Focuses: | Cc: |
Description
The WordPress Core development environment does not include proper Xdebug configuration for debugging from host IDEs like VS Code. While Xdebug is enabled in the PHP container, the client_host setting defaults to localhost, which prevents debugging connections from working when the IDE is running on the host machine.
Steps to Reproduce:
- Clone the wordpress-develop repository
- Set
LOCAL_PHP_XDEBUG=truein.envto enable Xdebug - Run the WordPress instance with instructions given in README.
- Configure VS Code to listen for Xdebug connections.
- Set breakpoints in PHP files
- Visit the WordPress site with Xdebug session enabled
Result:
Breakpoints are not triggered.
Expected:
Breakpoints should be triggered.
Attachments (2)
Change History (20)
#2
follow-up:
↓ 3
@
4 months ago
- Keywords reporter-feedback added
- Severity changed from minor to normal
#3
in reply to:
↑ 2
;
follow-up:
↓ 4
@
4 months ago
Replying to SirLouen:
What system are you using?
I'm on W11 with WSL2 and Ubuntu 24.04 and its working flawlessly.
I am using MacOS Sequoia (with Orbstack).
When you talk about breakpoints, apart from the bps in your ID, I'm assuming you are using either
xdebug_break()in code, or passing aXDEBUG_somethingquery var to the browser, or using a extension that injects it, right?
Xdebug uses
xdebug.start_with_request=triggerso you must trigger it; it's not perma-running as in regular setups.
Yup, I am using an extension (Xdebug Helper by JetBrains) in Chrome for the trigger.
#4
in reply to:
↑ 3
;
follow-up:
↓ 5
@
4 months ago
Replying to jdeep:
I am using MacOS Sequoia (with Orbstack).
Networking in that Orbstack might be the culprit specially if you happen to find that xdebug.client_host=host.docker.internal works for you
Which client are you using to connect to Xdebug?
#5
in reply to:
↑ 4
@
4 months ago
Replying to SirLouen:
Replying to jdeep:
I am using MacOS Sequoia (with Orbstack).
Networking in that Orbstack might be the culprit specially if you happen to find that
xdebug.client_host=host.docker.internalworks for you
Possible. However, after a lot of digging through docs and StackOverflow, I found that this is common issue with XDebug running inside a container. For example, PHPStorm's Xdebug client puts xdebug.client_host=host.docker.internal in config as well.
Which client are you using to connect to Xdebug?
I am using PHPDebug (by XDebug.org) extension in VSCode.
#6
follow-up:
↓ 7
@
4 months ago
I am using PHPDebug (by XDebug.org) extension in VSCode.
What is the VSCode you are using?
#7
in reply to:
↑ 6
;
follow-up:
↓ 8
@
4 months ago
Replying to SirLouen:
I am using PHPDebug (by XDebug.org) extension in VSCode.
What is the VSCode you are using?
Version: 1.103.2 (Universal)
Commit: 6f17636121051a53c88d3e605c491d22af2ba755
Date: 2025-08-20T16:45:34.255Z (3 wks ago)
Electron: 37.2.3
ElectronBuildId: 12035395
Chromium: 138.0.7204.100
Node.js: 22.17.0
V8: 13.8.500258-electron.0
OS: Darwin arm64 24.6.0
#8
in reply to:
↑ 7
;
follow-up:
↓ 9
@
4 months ago
Replying to jdeep:
Version: 1.103.2 (Universal) Commit: 6f17636121051a53c88d3e605c491d22af2ba755 Date: 2025-08-20T16:45:34.255Z (3 wks ago) Electron: 37.2.3 ElectronBuildId: 12035395 Chromium: 138.0.7204.100 Node.js: 22.17.0 V8: 13.8.500258-electron.0 OS: Darwin arm64 24.6.0
My bad. I was willing to ask, what is the launch.json file you are using in VSCode.
#9
in reply to:
↑ 8
@
4 months ago
Replying to SirLouen:
Replying to jdeep:
Version: 1.103.2 (Universal) Commit: 6f17636121051a53c88d3e605c491d22af2ba755 Date: 2025-08-20T16:45:34.255Z (3 wks ago) Electron: 37.2.3 ElectronBuildId: 12035395 Chromium: 138.0.7204.100 Node.js: 22.17.0 V8: 13.8.500258-electron.0 OS: Darwin arm64 24.6.0My bad. I was willing to ask, what is the
launch.jsonfile you are using in VSCode.
Yeah. This is my launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/var/www": "${workspaceFolder}",
"/var/www/src": "${workspaceFolder}/src",
"/var/www/build": "${workspaceFolder}/build"
},
"hostname": "0.0.0.0",
"xdebugSettings": {
"max_children": 128,
"max_data": 2048,
"max_depth": 3
}
},
]
}
#10
@
4 months ago
I've tested it, and it works for me with the Docker host.docker.internal hostname explicitly added in the PHP config.
Your VSCode file looks good to me.
#12
@
7 days ago
- Keywords commit added; needs-testing removed
- Milestone changed from Awaiting Review to 6.9.1
- Owner set to SirLouen
- Status changed from new to reviewing
I'm starting to have the same issue; I'm not sure why. I remember that I triaged this some months ago, so looking back in my history, I found this.
So basically I've tested it, and I can confirm that this patch solves this problem. ✅
This ticket was mentioned in Slack in #core by sirlouen. View the logs.
7 days ago
#14
follow-up:
↓ 15
@
7 days ago
Xdebug is working for me on a Mac, with and without this patch. Gemini explained to me why it works on a Mac without the patch but it fails on Windows with WSL:
Windows (WSL2): WSL2 runs as a distinct, lightweight Linux Virtual Machine. It has its own IP address and its own "Loopback" interface (
127.0.0.1). When Xdebug tries to connect tolocalhost, it connects to the container's own internal network. Since PhpStorm isn't installed inside the container, the connection fails.
The Fix:
host.docker.internalis a special DNS name Docker adds to the container specifically to resolve to the Host's internal IP address.
macOS: While also a VM, Docker Desktop for Mac binds ports and handles networking differently to make it feel more "native." However, relying on localhost here is technically "incorrect" for Docker and often breaks if you change network modes.
Moreover, it suggests an additional "universal" fix:
Instead of forcing your colleague to change their config to
host.docker.internaland you keepinglocalhost, you should both use the Discovery mode. This works on Mac, Windows, and Linux without changing a single line of config.
Change your php.ini (or Xdebug config) to:
# 1. Turn on Discovery xdebug.discover_client_host = true # 2. Set client_host as a fallback only (can be left as localhost or host.docker.internal) xdebug.client_host = host.docker.internalWhy this is better: When
discover_client_hostistrue, Xdebug ignores theclient_hostsetting. Instead, it looks at the incoming HTTP request headers (like$_SERVER['REMOTE_ADDR']) to find the IP address of the computer that sent the request (your computer). It then connects back to that IP automatically.
Summary for your Windows Colleague
Because WSL2 is a real Linux VM, localhost points to the Linux VM, not Windows. You have to use host.docker.internal so the container knows how to route out of the VM and talk to PhpStorm on Windows.
In reading the Xdebug docs about discover_client_host, it seems to make sense. Do note there is a warning, however:
Please note that there is no filter available, and anybody who can connect to the webserver will then be able to start a debugging session, even if their address does not match xdebug.client_host.
But since the wordpress-develop environment is local, there doesn't seem to be any concern here.
So should the patch be amended to include xdebug.discover_client_host=true?
#15
in reply to:
↑ 14
@
4 days ago
Replying to westonruter:
Xdebug is working for me on a Mac, with and without this patch. Gemini explained to me why it works on a Mac without the patch but it fails on Windows with WSL:
Yes, xdebug is a bit hateful occasionally. Now I'm testing, and it's working for me without any changes to the php-config.ini file.
I think that adding these two little tweaks, both the client_host and the discover_client_host have proven to fix issues and won't do any harm and will provide more robustness to any run.
What system are you using?
I'm on W11 with WSL2 and Ubuntu 24.04 and its working flawlessly.
When you talk about breakpoints, apart from the bps in your ID, I'm assuming you are using either
xdebug_break()in code, or passing aXDEBUG_somethingquery var to the browser, or using a extension that injects it, right?Xdebug uses
xdebug.start_with_request=triggerso you must trigger it; it's not perma-running as in regular setups.