Skip to content

Timed out waiting for debuggee to spawn: VS Code Fails to Send "attach" Request to debugpy Adapter After Successful "initialize" Response (Windows) #1897

@mborsetti

Description

@mborsetti

Before creating a new issue, please check the FAQ to see if your question is answered there.

Not answered there

Environment data

  • debugpy version: 1.8.14
  • OS and version: Windows 11 [Microsoft Windows NT 10.0.26100.0]
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.13.3 (tags/v3.13.3:6280bb5, Apr 8 2025, 14:47:33) [MSC v.1943 64 bit (AMD64)]
  • Using VS Code or Visual Studio: VS code 1.100.2, Electron 34.5.1, ElectronBuildId 11369351, Chromium 132.0.6834.210, Node.js 20.19.0, V8 13.2.154.41-electron0

Actual behavior

Suddenly the debugger would not launch and would always terminate after ~62 seconds with a "Timed out waiting for debuggee to spawn" error. Reproduceable.

Expected behavior

Debugger works!

Steps to reproduce:

Before the below I have:

  • Rebooted the computer more times that I can think of
  • Completely uninstalled VS code and deleted the install directory (all extension)
  • Reinstalled VS code with only Python extensions
  • Downgraded Python debugger extension and switched to pre-release version
  • Cleaned both User and Workspace settings.json
  • Poked at the Windows network stack (no firewall, netsh int ip reset. etc. etc.)
  • Assured that the port was published (netstat -ano) and reachable (Test-NetConnection)
  • Lots of other troubleshooting

I finally isolated this error to VS Code failing to send an "attach" request to the debugpy adapter after receiving a successful "initialize" response.

To reproduce the issue and eliminate any confounders, I:

  • Created a new virtual environment
  • Disabled all extensions other than Python Debugger (version 2025.8.0) and its two dependencies (Python 2025.6.1 and Pylance 2025.5.1
  • Installed debugpy (version: 1.8.14) via pip.

In this minimal, stripped-down, setup, I ran this script:

# test_debug.py
import os

import debugpy

debugpy.log_to(os.getcwd())
print(f"Attempting to start debugpy (version {debugpy.__version__}) listener...")
try:
    host = "localhost"
    port = 5678
    debugpy.listen((host, port))
    print(f"debugpy listening on host {host}, port {5678}")
    print("Waiting for debugger to attach...")
    debugpy.wait_for_client()
    print("Debugger attached!")
except Exception as e:
    print(f"Error starting debugpy: {e}")
    exit()

print("Script finished.")

I then ran it, and the terminal output would read:

(.venv) PS C:\Users\mike\Documents\python\test_debugpy> & c:/Users/mike/Documents/python/test_debugpy/.venv/Scripts/python.exe c:/Users/mike/Documents/python/test_debugpy/test.py
Attempting to start debugpy (version 1.8.14) listener...
debugpy listening on host localhost, port 5678
Waiting for debugger to attach...

I would then attach the VS Code debugger with the following 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": "Attach to adapter",
            "type": "debugpy",
            "request": "attach",
            "connect": {
                "host": "localhost",
                "port": 5678
            },
            "logToFile": true
        }
    ]
}

After doing so, tho Output (Python Debugger) window would read:

2025-05-23 06:54:45.640 [info] Resolving attach configuration with substituted variables
2025-05-23 06:54:45.644 [info] Connecting to DAP Server at:  localhost:5678

After this, the debugger would be completely stuck and never fully initialize, rendering debugging impossible. The script would remain stuck at "Waiting for debugger to attach..." and fail to execute further.

This is the debugger.vscode log file:

0 Starting Session:
{
    "name": "Attach to adapter",
    "type": "debugpy",
    "request": "attach",
    "connect": {
        "host": "localhost",
        "port": 5678
    },
    "logToFile": true,
    "__configurationTarget": 6,
    "clientOS": "windows",
    "debugOptions": [
        "RedirectOutput",
        "ShowReturnValue"
    ],
    "justMyCode": true,
    "showReturnValue": true,
    "workspaceFolder": "c:\\Users\\mike\\Documents\\python\\test_debugpy"
}
18 Client <-- Adapter:
{
    "seq": 1,
    "type": "event",
    "event": "output",
    "body": {
        "category": "telemetry",
        "output": "ptvsd",
        "data": {
            "packageVersion": "1.8.14"
        }
    }
}
23 Client --> Adapter:
{
    "command": "initialize",
    "arguments": {
        "clientID": "vscode",
        "clientName": "Visual Studio Code",
        "adapterID": "debugpy",
        "pathFormat": "path",
        "linesStartAt1": true,
        "columnsStartAt1": true,
        "supportsVariableType": true,
        "supportsVariablePaging": true,
        "supportsRunInTerminalRequest": true,
        "locale": "en",
        "supportsProgressReporting": true,
        "supportsInvalidatedEvent": true,
        "supportsMemoryReferences": true,
        "supportsArgsCanBeInterpretedByShell": true,
        "supportsMemoryEvent": true,
        "supportsStartDebuggingRequest": true,
        "supportsANSIStyling": true
    },
    "type": "request",
    "seq": 1
}

As you can see, it gets stuck after the "initialize" command, and not go any further

This is the debugpy.adapter log file:

I+00000.125: Windows-11-10.0.26100-SP0 AMD64
             CPython 3.13.3 (64-bit)
             debugpy 1.8.14

I+00000.174: debugpy.adapter startup environment:
             
             System paths:
                 sys.executable: C:\Users\mike\Documents\python\test_debugpy\.venv\Scripts\python.exe
                 sys.prefix: C:\Users\mike\Documents\python\test_debugpy\.venv
                 sys.base_prefix: C:\Program Files\Python\Python313
                 sys.real_prefix: <missing>
                 site.getsitepackages(): C:\Users\mike\Documents\python\test_debugpy\.venv
                                         C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages
                 site.getusersitepackages(): C:\Users\mike\AppData\Roaming\Python\Python313\site-packages
                 sys.path (site-packages): C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages
                 sysconfig.get_path('stdlib'): C:\Program Files\Python\Python313\Lib
                 sysconfig.get_path('platstdlib'): C:\Users\mike\Documents\python\test_debugpy\.venv\Lib
                 sysconfig.get_path('purelib'): C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages
                 sysconfig.get_path('platlib'): C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages
                 sysconfig.get_path('include'): C:\Program Files\Python\Python313\Include(C:\Program Files\Python\Python313\include)
                 sysconfig.get_path('scripts'): C:\Users\mike\Documents\python\test_debugpy\.venv\Scripts
                 sysconfig.get_path('data'): C:\Users\mike\Documents\python\test_debugpy\.venv
                 os.__file__: C:\Program Files\Python\Python313\Lib\os.py
                 threading.__file__: C:\Program Files\Python\Python313\Lib\threading.py
                 debugpy.__file__: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\__init__.py
             
             Installed packages:
                 debugpy==1.8.14
                 pip==25.1.1

I+00000.177: Listening for incoming Client connections on 127.0.0.1:5678...

I+00000.177: Listening for incoming Server connections on 127.0.0.1:54329...

I+00000.178: Sending endpoints info to debug server at localhost:54328:
             {
                 "client": {
                     "host": "127.0.0.1",
                     "port": 5678
                 },
                 "server": {
                     "host": "127.0.0.1",
                     "port": 54329
                 }
             }

I+00000.182: Accepted incoming Server connection from 127.0.0.1:54331.

D+00000.182: Starting message loop for channel Server[?]

D+00000.182: Server[?] <-- {
                 "seq": 1,
                 "type": "request",
                 "command": "pydevdAuthorize",
                 "arguments": {
                     "debugServerAccessToken": "afc6e7f2a6c050d62cc59edd15c1086b7b041565c35634085a18ec186aacd34c"
                 }
             }

D+00000.183: Server[?] --> {
                 "pydevd_cmd_id": 502,
                 "seq": 2,
                 "type": "response",
                 "request_seq": 1,
                 "success": true,
                 "command": "pydevdAuthorize",
                 "body": {
                     "clientAccessToken": null
                 }
             }

D+00000.184: Server[?] <-- {
                 "seq": 2,
                 "type": "request",
                 "command": "pydevdSystemInfo"
             }

This is the debugpy.pydevd log file:

0.44s - pydevd: Use libraries filter: False

0.00s - IDE_PROJECT_ROOTS []

0.00s - Collecting default library roots.
0.00s - LIBRARY_ROOTS ['C:\\Program Files\\Python\\Python313\\Lib', 'C:\\Users\\mike\\AppData\\Roaming\\Python\\Python313\\site-packages', 'C:\\Users\\mike\\Documents\\python\\test_debugpy\\.venv', 'C:\\Users\\mike\\Documents\\python\\test_debugpy\\.venv\\Lib', 'C:\\Users\\mike\\Documents\\python\\test_debugpy\\.venv\\Lib\\site-packages']

0.00s - Apply debug mode: debugpy-dap
0.00s - Preimport: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages;debugpy._vendored.force_pydevd
0.00s - Connecting to 127.0.0.1:54329
0.00s - Connected to: <socket.socket fd=616, family=2, type=1, proto=0, laddr=('127.0.0.1', 54331), raddr=('127.0.0.1', 54329)>.
0.00s - Applying patching to hide pydevd threads (Py3 version).
0.00s - Process PydevdAuthorizeRequest: {
    "arguments": {
        "debugServerAccessToken": "afc6e7f2a6c050d62cc59edd15c1086b7b041565c35634085a18ec186aacd34c"
    },
    "command": "pydevdAuthorize",
    "seq": 1,
    "type": "request"
}

0.00s - sending cmd (http_json) -->           CMD_RETURN {"type": "response", "request_seq": 1, "success": true, "command": "pydevdAuthorize", "body": {"clientAccessToken": null}, "seq": 2, "pydevd_cmd_id": 502}

0.10s - SKIP set tracing of frame: C:\Program Files\Python\Python313\Lib\threading.py - wait
0.00s - SKIP set tracing of frame: C:\Program Files\Python\Python313\Lib\threading.py - wait
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\_vendored\pydevd\pydevd.py - _on_run
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_daemon_thread.py - run
0.00s - SKIP set tracing of frame: C:\Program Files\Python\Python313\Lib\threading.py - _bootstrap_inner
0.00s - SKIP set tracing of frame: C:\Program Files\Python\Python313\Lib\threading.py - _bootstrap
0.00s - SKIP set tracing of frame: C:\Program Files\Python\Python313\Lib\threading.py - wait
0.00s - SKIP set tracing of frame: C:\Program Files\Python\Python313\Lib\threading.py - wait
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\_vendored\pydevd\pydevd.py - _on_run
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_daemon_thread.py - run
0.00s - SKIP set tracing of frame: C:\Program Files\Python\Python313\Lib\threading.py - _bootstrap_inner
0.00s - SKIP set tracing of frame: C:\Program Files\Python\Python313\Lib\threading.py - _bootstrap
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py - _read_line
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py - _on_run
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_daemon_thread.py - run
0.00s - SKIP set tracing of frame: C:\Program Files\Python\Python313\Lib\threading.py - _bootstrap_inner
0.00s - SKIP set tracing of frame: C:\Program Files\Python\Python313\Lib\threading.py - _bootstrap
0.00s - SKIP set tracing of frame: C:\Program Files\Python\Python313\Lib\threading.py - wait
0.00s - SKIP set tracing of frame: C:\Program Files\Python\Python313\Lib\queue.py - get
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py - _on_run
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_daemon_thread.py - run
0.00s - SKIP set tracing of frame: C:\Program Files\Python\Python313\Lib\threading.py - _bootstrap_inner
0.00s - SKIP set tracing of frame: C:\Program Files\Python\Python313\Lib\threading.py - _bootstrap
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\_vendored\pydevd\pydevd.py - set_tracing_for_untraced_contexts
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\_vendored\pydevd\pydevd.py - _locked_settrace
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\_vendored\pydevd\pydevd.py - settrace
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\server\api.py - _settrace
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\server\api.py - listen
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\server\api.py - debug
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\public_api.py - wrapper
0.00s - Set tracing of frame: c:\Users\mike\Documents\python\test_debugpy\test.py - <module>
0.00s - File traced: c:\Users\mike\Documents\python\test_debugpy\test.py (force_check_project_scope)
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\_vendored\pydevd\pydevd.py - settrace
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\server\api.py - _settrace
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\server\api.py - listen
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\server\api.py - debug
0.00s - SKIP set tracing of frame: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\public_api.py - wrapper
0.00s - Set tracing of frame: c:\Users\mike\Documents\python\test_debugpy\test.py - <module>

This is the debugpy.server log file:

I+00000.108: Windows-11-10.0.26100-SP0 AMD64
             CPython 3.13.3 (64-bit)
             debugpy 1.8.14

I+00000.133: Initial environment:
             
             System paths:
                 sys.executable: C:\Users\mike\Documents\python\test_debugpy\.venv\Scripts\python.exe
                 sys.prefix: C:\Users\mike\Documents\python\test_debugpy\.venv
                 sys.base_prefix: C:\Program Files\Python\Python313
                 sys.real_prefix: <missing>
                 site.getsitepackages(): C:\Users\mike\Documents\python\test_debugpy\.venv
                                         C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages
                 site.getusersitepackages(): C:\Users\mike\AppData\Roaming\Python\Python313\site-packages
                 sys.path (site-packages): C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages
                 sysconfig.get_path('stdlib'): C:\Program Files\Python\Python313\Lib
                 sysconfig.get_path('platstdlib'): C:\Users\mike\Documents\python\test_debugpy\.venv\Lib
                 sysconfig.get_path('purelib'): C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages
                 sysconfig.get_path('platlib'): C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages
                 sysconfig.get_path('include'): C:\Program Files\Python\Python313\Include(C:\Program Files\Python\Python313\include)
                 sysconfig.get_path('scripts'): C:\Users\mike\Documents\python\test_debugpy\.venv\Scripts
                 sysconfig.get_path('data'): C:\Users\mike\Documents\python\test_debugpy\.venv
                 os.__file__: C:\Program Files\Python\Python313\Lib\os.py
                 threading.__file__: C:\Program Files\Python\Python313\Lib\threading.py
                 debugpy.__file__: C:\Users\mike\Documents\python\test_debugpy\.venv\Lib\site-packages\debugpy\__init__.py
             
             Installed packages:
                 debugpy==1.8.14
                 pip==25.1.1

D+00000.133: listen(('localhost', 5678), **{})

I+00000.133: Initial debug configuration: {
                 "qt": "none",
                 "subProcess": true,
                 "python": "C:\\Users\\mike\\Documents\\python\\test_debugpy\\.venv\\Scripts\\python.exe",
                 "pythonEnv": {}
             }

I+00000.135: Waiting for adapter endpoints on 127.0.0.1:54328...

I+00000.135: debugpy.listen() spawning adapter: [
                 "C:\\Users\\mike\\Documents\\python\\test_debugpy\\.venv\\Scripts\\python.exe",
                 "C:\\Users\\mike\\Documents\\python\\test_debugpy\\.venv\\Lib\\site-packages\\debugpy\\adapter",
                 "--for-server",
                 "54328",
                 "--host",
                 "localhost",
                 "--port",
                 "5678",
                 "--server-access-token",
                 "afc6e7f2a6c050d62cc59edd15c1086b7b041565c35634085a18ec186aacd34c",
                 "--log-dir",
                 "C:\\Users\\mike\\Documents\\python\\test_debugpy"
             ]

I+00000.395: Endpoints received from adapter: {
                 "client": {
                     "host": "127.0.0.1",
                     "port": 5678
                 },
                 "server": {
                     "host": "127.0.0.1",
                     "port": 54329
                 }
             }

I+00000.395: Adapter is accepting incoming client connections on 127.0.0.1:5678

D+00000.395: pydevd.settrace(*(), **{'host': '127.0.0.1', 'port': 54329, 'wait_for_ready_to_run': False, 'block_until_connected': True, 'access_token': 'afc6e7f2a6c050d62cc59edd15c1086b7b041565c35634085a18ec186aacd34c', 'suspend': False, 'patch_multiprocessing': True, 'dont_trace_start_patterns': ('C:\\Users\\mike\\Documents\\python\\test_debugpy\\.venv\\Lib\\site-packages\\debugpy',), 'dont_trace_end_patterns': ('debugpy_launcher.py',)})

I+00000.506: pydevd is connected to adapter at 127.0.0.1:54329

D+00000.506: wait_for_client()

Any suggestions welcomed -- it's impossible to do any meaningful work without a debugger!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions