Skip to content

The debugging session fails silently immediately after clicking 'Start Debugging' (On Windows only) #1807

Closed

Description

At some point last year, debugging python code in vscode stopped working on my work laptop (running Windows 10). The problem only occurs when I open a folder/workspace in Windows. I mostly work in Linux in VSCode through the WSL remote connection. When connected through WSL, the debugging extension works without problems. I mostly work through WSL, so I ignored the problems I had on Windows. Now, months later, we're experiencing a crash in our Python code that only occurs on Windows. Not being able to run with debugging in Windows VSCode is making it really hard to help out my colleages.

So far I tried reviewing my launch.json and settings.json, updating the extension to the latest version and the latest pre-release version, and checking the 'Python Debugger' output pane.

The problem

I created a few configurations in my launch.json. Some for specific python programs, and one for the pytest test suite. If I click 'Start debugging', nothing much seems to happen:

  • A 'loading bar' and the tiny 'debug' menu (with the continue, step, stop and pause buttons) flash on the screen for a fraction of a second, then disappear.
  • The 'Python Debugger' output shows two new lines:
    • Resolving launch configuration with substituted variables
    • DAP Server launched with command: <my-repo-dir>\.venv\Scripts\python <home-dir>\.vscode\extensions\ms-python.debugpy-2024.15.2024121701-win32-x64\bundled\libs\debugpy\adapter

I configured the test discovery in vscode, and I can run our test suite just fine. But when I click 'Debug test' on any test, the test doesn't run. The spinner seems to run indefinitely. I get the same two lines as above in the 'Python Debugger' output.

I should mention that I have been able to debug with python just fine in the past, and not much has changed in my configuration since (if anything, I don't know if the problem occurred because of a settings change). As far as I can tell I'm using a bogstandard vscode configuration for a simple python project.

Using the logToFile option in launch.json

The only progress I made is to add "logToFile": true to my debug configuration in launch.json. I can tell from the Python Debugger output that the extension is invoking a python program called adapter with an option to write a log file to my home directory (where my vscode extensions are stored). It didn't help me much, but maybe it can be of some help to you, so I'll attach the logfile to this issue.

debugger.vscode_uuid.log

Is there any way to see more verbose output than this? Or is there some other log I could check? I'm kind of stumped at this point, and I could use your help.

My configuration

VSCode:
Version: 1.96.2 (user setup)
Commit: fabdb6a30b49f79a7aba0f2ad9df9b399473380f
Date: 2024-12-19T10:22:47.216Z
Electron: 32.2.6
ElectronBuildId: 10629634
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.19045

VSCode extensions:
ms-python.python: 2024.22.2
ms-python.debugpy: 2024.15.2024121701

Python: 3.12.0

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug my-program",
            "type": "debugpy",
            "request": "launch",
            "program": "${workspaceFolder}\\my-program.py",
            "logToFile": true,
            "args": [
                "--flag",
                "--with=argument"
            ],
            "console": "integratedTerminal",
            "justMyCode": false
        },
        // ...
    ]
}

settings.json

{
    "python.defaultInterpreterPath": "${workspaceFolder}\\.venv\\Scripts\\python.exe",
    "python.terminal.activateEnvironment": true,
    "python.testing.pytestEnabled": true,
    "python.testing.autoTestDiscoverOnSaveEnabled": true,
    "python.envFile": "${workspaceFolder}\\.env",
    // ...
}

Thanks!

Activity

  1. added
    needs repro
    on Jan 14, 2025
  2. rchiodo commented on Jan 14, 2025

    @rchiodo
    Contributor

    I guess I'd try running debugpy manually from the terminal. It seems like something is crashing on startup.

    You could try the specific command line used by VS code:

    'c:\Users\rchiodo\source\testing\test_pylance\.venv313\Scripts\python.exe' 'c:\Users\rchiodo\.vscode-insiders\extensions\ms-python.debugpy-2024.15.2024121701-win32-x64\bundled\libs\debugpy\launcher' '53226' '--' 'c:\Users\rchiodo\source\testing\test_pylance\test_debugging.py'
    

    Or you could try something simpler. Install debugpy into your .venv and run this:

    python -m debugpy --listen 5678 yourscript.py
    

    And see what happens. That latter command can be attached to from VS code.

  3. rene-deltares commented on Jan 15, 2025

    @rene-deltares
    Author

    Interesting, it hadn't occurred to me that I could install debugpy from pypi and run it.

    So I installed debugpy==1.8.11 in my virtual environment (that version matches the one bundled with the vscode extension), and I start the server like this:

    python -m debugpy --listen 5678 --wait-for-client .\my_script.py --flag --with=argument

    I use this attach configuration in launch.json

    {
      "name": "Attach to adapter",
      "type": "debugpy",
      "request": "attach",
      "connect": {
        "host": "127.0.0.1",
        "port": 5678
      }
    }

    Now I can set breakpoints in vscode, and when I select the Attach to adapter launch configuration, the debugging works! The program runs and my breakpoints are getting hit in vscode. So at least I now have a workaround for the problem and that's already progress. Thanks!

    I don't think I got the launcher program working. I suspect the problem is there, but I'm a bit confused about how I'm supposed to use it. I tried this command:

    python '<home_dir>\.vscode\extensions\ms-python.debugpy-2024.15.2024121701-win32-x64\bundled\libs\debugpy\launcher' '53226' '--' .\my_script.py --flag --with=argument

    I get a ConnectionRefusedErrors

    debugpy\launcher/../..\debugpy\launcher\__init__.py", line 27, in connect
        sock.connect((host, port))
    ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
    

    So I figured I first need to start a server listening on port '53226' before running the command, right? I tried this:

    python -m debugpy --listen 53226 --wait-for-client .\my_script.py --flag --with=argument

    Now I start getting confused because I don't know if I should be invoking my script+arguments with debugpy or launcher

    I retry the launcher command again:

    python '<home_dir>\.vscode\extensions\ms-python.debugpy-2024.15.2024121701-win32-x64\bundled\libs\debugpy\launcher' '53226' '--' .\my_script.py --flag --with=argument

    Now there's no ConnectionRefusedError, but the launcher program exits without showing any output, and my program is not run. I found out by reading the launcher code that it writes logs to a directory set by the DEBUGPY_LOG_DIR env variable. So I again attached some logs for the launcher program:

    debugpy.launcher-15444.log

  4. rchiodo commented on Jan 15, 2025

    @rchiodo
    Contributor

    You can't actually debug with the launcher command, that's what VS code does. It opens the port that the launcher is talking to. I wanted you to try that to see if it threw any errors on the command line just from running debugpy, but maybe it's happening after the port is written to.

    If you go back to the launch that you originally used, it has logToFile set. It should be writing out a bunch of logs here:

    C:\Users\rchiodo\.vscode\extensions\ms-python.debugpy-2024.15.2024121701-win32-x64
    

    Delete all the logs and try running it again. Then if you upload those logs here, it might have more information.

  5. pecey commented on Sep 23, 2025

    @pecey

    Hi. I have the same issue. I have verified that I can attach if I start debugpy separately, but when I launch the debugger from VSCode it fails. In my case, I am running on WSL and connecting to a unix server via SSH.

    The log is very similar to the one attached already.

    debugpy.log

    Happy to provide any more information or logs.

  6. rchiodo commented on Sep 23, 2025

    @rchiodo
    Contributor

    Your log looks like debugpy is failing to start. I'd try running it from the terminal in VS code.

    The command would look something like this:

    'c:\Users\rchiodo\source\testing\test_pylance\.venv313\Scripts\python.exe' 'c:\Users\rchiodo\.vscode-insiders\extensions\ms-python.debugpy-2024.15.2024121701-win32-x64\bundled\libs\debugpy\launcher' '53226' '--' 'c:\Users\rchiodo\source\testing\test_pylance\test_debugging.py'
    

    Although I'm pretty sure you should see it in the terminal. Try just running that same command and see if it gives you an error.

  7. pecey commented on Sep 24, 2025

    @pecey

    I don't see it in the terminal. Whenever I click on any other configuration that should launch debugpy (and which used to work previously), it fails to launch and dies. I don't see any command in the terminal window. I was trying to form the unix equivalent of the command you mentioned, but I cannot find .vscode-insiders in my home directory. I just have .vscode and .vscode-server. Inside .vscode, I have a similar folder structure (.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/launcher) and so I replaced it in the command.
    I executed the following from within my venv
    python /home/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/launcher 53226 -- /home/Research/project/learn.py

    I get a ConnectionRefusedError. Is there anything is specific that I should be looking at? I tried changing the port number, but it doesn't work.

    EDIT: I can connect to the same server from VSCode running on a unix machine at work, while connecting from Windows while being on the same network fails.

  8. rchiodo commented on Sep 24, 2025

    @rchiodo
    Contributor

    Maybe the port is not open? The launch command will try to connect to a port on the remote machine. AFAIK, VS code should forward that port, but maybe that's not working.

    What I was hoping you could try would be to just run debugpy by itself using the launch command line inside of the VS Code terminal

    python <path extension's debugpy in wsl>  --listen 5678 --wait-for-client <script name>
    

    That should setup debugpy to start the python process and wait for VS code to attach on 5678.

    If that worked, you should be able to 'attach' to that port and it would essentially be the same as launch.

  9. pecey commented on Sep 24, 2025

    @pecey

    Just to clarify, in my previous comment, when I said I ran
    python /home/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/launcher 53226 -- /home/Research/project/learn.py from my venv, I meant from my WSL terminal, outside VSCode. I am not sure if that helps anyhow.

    About the port not being open - I can try running the exact same command from VSCode running on unix, if that helps narrow down the issue. Is there anything I should check on the server side?

    Also, when I try
    python -m debugpy --listen 5678 --wait-for-client <script name>, then I am able to use the attach configuration to attach VSCode.

    I don't know if this is what you meant by <path extension's debugpy in wsl>.

  10. rchiodo commented on Sep 24, 2025

    @rchiodo
    Contributor

    Also, when I try
    python -m debugpy --listen 5678 --wait-for-client <script name>, then I am able to use the attach configuration to attach VSCode.

    That would be using the debugpy in your python environment. VS code uses the debugpy in the extensions folder. There might be some mismatch going on but it doesn't seem likely to me. Running a different version of debugpy shouldn't cause it to just exit.

    I'm also not sure that it's actually a port problem as running this:

    python /home/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/launcher 53226 -- /home/Research/project/learn.py
    

    isn't going to work because there's nothing listening on 53226. VS code would have opened that port when you started debugging.

    Before you sent the debugpy.log. There should actually be 4 log files. One of them should be from debugpy actually starting the process. Can you include all of them?

  11. pecey commented on Sep 24, 2025

    @pecey

    Can you please tell me where should I be looking for the logs? When I sent the previous log, if memory serves me right, I found them inside .vscode-server/extensions/ms-python.debugpy-2025.10.0-linux-x64. I deleted the older logs, and connected VSCode to the server and started the debug session, but no logs seem to be registered inside the .vscode-server/extensions location. I have a file inside .vscode-server/cli/servers that I am attaching here.

    log.txt

    I found a couple of other log files being written inside .vscode-server/data/logs. Are they the ones you were referencing?

  12. rchiodo commented on Sep 24, 2025

    @rchiodo
    Contributor

    If you have logToFile set to true in your launch.json, the logs should end up in the .vscode-server/extensions/ms-python.debugpy-<version> folder you mentioned above.

  13. pecey commented on Sep 24, 2025

    @pecey

    Thanks. I was missing logToFile. But only one log file is being generated at the location and is similar to the one I sent previously. I am attaching it here.

    debugger.vscode_9485b94c-52f7-4df0-8a8a-da17a61e8f01.log

  14. 5 remaining items

  15. pecey commented on Sep 25, 2025

    @pecey

    In VSCode, my python interpreter points to the venv itself and the terminal points to the same.

    I get the following when I set the log level to trace.

    Image

    For some reason, it is calling .vscode-server/extensions/ms-python.debugpy-2025.10.0-linux-x64 rather than .vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64. If I run the command it uses from the terminal, then I get a can't find 'main' module, but switching it to .vscode/extensions gives me a response

    Image
  16. rchiodo commented on Sep 25, 2025

    @rchiodo
    Contributor

    In WSL it should be running from the ~/.vscode-server/extensions folder. Well assuming you used the WSL remoting option. VS code should be running an extension host process from the ~/.vscode-server folder

    Maybe the extension is corrupted. You could try clearing the .vscode-server folder in WSL and then reconnecting to WSL and reinstalling the extensions.

  17. luifire commented on Jan 21, 2026

    @luifire

    I have the same issue.
    I fixed it by creating a hard link
    mklink /H python python.exe

    Not pretty, but works for now.

  18. luifire commented on Jan 23, 2026

    @luifire

    Reinstalling VSCode fixed the issue entirely.

  19. added
    bug
    on Feb 5, 2026
  20. JusicP commented on May 5, 2026

    @JusicP

    Same issue. Debug session starts and closes silently without any understandable trace.
    But to my surprise, the problem was in venv directory name ".venv":

    "python.defaultInterpreterPath": "${workspaceFolder}/.venv/Scripts/python.exe",
    

    After i renamed the venv directory (just removed the dot) debugging worked fine:

    "python.defaultInterpreterPath": "${workspaceFolder}/venv/Scripts/python.exe",
    

    I leave debugger logs with both ".venv" and "venv" variants.

    debugger.vscode .venv.log
    debugger.vscode venv.log

  21. rchiodo commented on May 5, 2026

    @rchiodo
    Contributor

    JusicP, a . in the venv should have no effect on running debugpy. Can you try running it manually? What does the 'Python Debugger' output tab show when the command ran?

  22. JusicP commented on May 5, 2026

    @JusicP

    . in name really have no effect, but .venv does. I tried name it .test, everything worked fine.
    ...
    After restarting PC, .venv variant worked, but can't reproduce the problem anymore. I compared debugger.vscode logs and noticed a difference:

        "python": "d:\\JusicP\\S\\server\\.venv\\Scripts\\python.exe",
    

    BEFORE:

        "python": "d:\\JusicP\\S\\server\\.venv\\Scripts\\python",
    

    no .exe at the end. Maybe that was the problem, but .exe ending was explicitly set in python.defaultInterpreterPath

  23. rchiodo commented on May 5, 2026

    @rchiodo
    Contributor

    Hmm, sounds like a bug in the Python environments extension when returning the path to the python executable. Maybe a restart updated something.

  24. JusicP commented on May 5, 2026

    @JusicP

    Ok now I able to reproduce this. I removed .exe from python.defaultInterpreterPath, ran debug. Then i put .exe back and like nothing changed - debugger doesn't work and python is without extension in logs. Even after vscode restart.

    Python Debugger tab logs:

    2026-05-05 23:15:30.391 [info] resolveDebugConfigurationWithSubstitutedVariables: resolving interpreter for program='D:\JusicP\S\server\main.py'
    2026-05-05 23:15:30.392 [info] legacyGetInterpreterDetails: executable='d:\JusicP\S\server\.venv\Scripts\python' resource='d:\JusicP\S\server\main.py'
    2026-05-05 23:15:30.393 [info] resolveDebugConfigurationWithSubstitutedVariables: setting debugConfiguration.python='d:\JusicP\S\server\.venv\Scripts\python'
    2026-05-05 23:15:30.393 [info] Resolving launch configuration with substituted variables
    2026-05-05 23:15:30.401 [info] createDebugAdapterDescriptor: request='launch' name='Python Debugger: Current File'
    2026-05-05 23:15:30.403 [info] legacyGetInterpreterDetails: executable='d:\JusicP\S\server\.venv\Scripts\python' resource='d:\JusicP\S\server'
    2026-05-05 23:15:30.404 [info] legacyResolveEnvironment: Resolving environment 'd:\JusicP\S\server\.venv\Scripts\python'
    2026-05-05 23:15:30.404 [info] legacyResolveEnvironment: Resolved executable='d:\JusicP\S\server\.venv\Scripts\python'
    2026-05-05 23:15:30.404 [info] resolveEnvironment: legacy resolved executable='d:\JusicP\S\server\.venv\Scripts\python' version='3.14.0'
    2026-05-05 23:15:30.405 [info] getExecutableCommand: executable='d:\JusicP\S\server\.venv\Scripts\python' version='3.14.0'
    2026-05-05 23:15:30.406 [info] createDebugAdapterDescriptor: python command parts='d:\JusicP\S\server\.venv\Scripts\python'
    2026-05-05 23:15:30.406 [info] DAP Server launched with command: d:\JusicP\S\server\.venv\Scripts\python c:\Users\123\.vscode\extensions\ms-python.debugpy-2026.6.0-win32-x64\bundled\libs\debugpy\adapter --log-dir c:\Users\123\.vscode\extensions\ms-python.debugpy-2026.6.0-win32-x64
    

    Looks like executable name is cached somewhere and not updated. But changing venv directory helps.

  25. rchiodo commented on May 5, 2026

    @rchiodo
    Contributor

    That would be a bug in the Python extension I believe. It handles the python.defaultInterpreterPath setting.
    https://github.com/microsoft/vscode-python/issues.

    Although I believe python.defaultInterpreterPath is a "legacy" setting and isn't supposed to be used anymore. I don't even see it in the list of allowed settings anymore.

  26. rchiodo commented on May 5, 2026

    @rchiodo
    Contributor

    Oh sorry, it seems it is supported, just only at the workspace level:
    https://github.com/microsoft/vscode-python/wiki/Setting-descriptions#pythondefaultinterpreterpath

    It not working would still be a bug on the Python extension though.

  27. rchiodo commented on May 5, 2026

    @rchiodo
    Contributor

    I'm going to close this otherwise. I don't think this is reproducing outside of this strange problem with the defaultInterpreterPath.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugneeds repro

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions