You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VSCode与Xdebug调试异常:调试按钮失效及连接失败问题求助

Xdebug无法连接VSCode,调试按钮未激活问题排查求助

我的母语并非英语,若表述有疏漏还请见谅。我已在VSCode中配置Xdebug用于PHP调试,但Xdebug的Step into、Step out、Step Over三个调试按钮处于未激活状态。

环境信息

PHP版本信息

执行php -v输出:

gerard@gerard-ThinkCentre-M700:~$ php -v
PHP 8.1.2-1ubuntu2.14 (cli) (built: Aug 18 2023 11:41:11) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.14, Copyright (c), by Zend Technologies
    with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans

Xdebug配置文件内容

路径:/etc/php/8.1/mods-available/xdebug.ini

zend_extension=xdebug.so
xdebug.mode = develop, debug
xdebug.start_with_request = yes
xdebug.log = /tmp/xdebug.log
xdebug.client_host = localhost
xdebug.client_port = 9003

相关截图

  • xdebug1
  • Xdebug2
  • Xdebug3

Xdebug日志内容

[10694] Log opened at 2024-03-15 08:52:39.285551
[10694] [Step Debug] INFO: Connecting to configured address/port: localhost:9003.
[10694] [Step Debug] WARN: Creating socket for 'localhost:9003', poll success, but error: Operation now in progress (29).
[10694] [Step Debug] ERR: Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_p>
[10694] Log closed at 2024-03-15 08:52:39.287093

[10696] Log opened at 2024-03-15 08:52:39.308197
[10696] [Step Debug] INFO: Connecting to configured address/port: localhost:9003.
[10696] [Step Debug] WARN: Creating socket for 'localhost:9003', poll success, but error: Operation now in progress (29).
[10696] [Step Debug] ERR: Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_p>
[10696] Log closed at 2024-03-15 08:52:39.308848

[10852] Log opened at 2024-03-15 08:52:58.522332
[10852] [Step Debug] INFO: Connecting to configured address/port: localhost:9003.
[10852] [Step Debug] WARN: Creating socket for 'localhost:9003', poll success, but error: Operation now in progress (29).
[10852] [Step Debug] ERR: Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_p>
[10852] Log closed at 2024-03-15 08:52:58.524340

[10853] Log opened at 2024-03-15 08:52:58.549547
[10853] [Step Debug] INFO: Connecting to configured address/port: localhost:9003.
[10853] [Step Debug] WARN: Creating socket for 'localhost:9003', poll success, but error: Operation now in progress (29).
[10853] [Step Debug] ERR: Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_p>
[10853] Log closed at 2024-03-15 08:52:58.550293

端口监听状态

调试器激活时执行netstat -an | grep 9003输出:

gerard@gerard-ThinkCentre-M700:~$ netstat -an | grep 9003
tcp6       0      0 :::9003                 :::*                    LISTEN     

VSCode launch.json配置

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9003
        }
    ]
}

恳请协助解决Xdebug无法连接VSCode,导致调试按钮未激活的问题。

内容的提问来源于stack exchange,提问作者Sam LIA

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 19:17:18