Adapter bootstrap fails with ConnectionRefusedError on WSL2 VirtioProxy or hostAddressLoopback

Aperta
#2,071 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

Inizia in debugpy/adapter/main.py, nella chiamata dell’adattatore a sock.connect((localhost, args.for_server)), quindi riproduci il problema con il comando uv run fornito in WSL2. Confronta il comportamento con networkingMode=VirtioProxy e hostAddressLoopback=true abilitati o disabilitati; il lavoro è completato quando debugpy.listen() si avvia senza ConnectionRefusedError con le impostazioni interessate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Environment data

  • debugpy version: 1.8.21
  • OS and version: Windows 11 build 26200.9106, Ubuntu 24.04 on WSL2
  • Python version (& distribution if applicable, e.g. Anaconda): CPython 3.14.4, installed/managed by uv
  • WSL version: 2.7.12.0
  • Using VS Code or Visual Studio: bash only

Actual behavior

debugpy.listen() consistently fails during its internal adapter bootstrap. The adapter immediately fails when connecting back to debugpy's temporary callback listener:

ConnectionRefusedError: [Errno 111] Connection refused

The relevant adapter log lines are:

Sending endpoints info to debug server at localhost:<port>
ConnectionRefusedError: [Errno 111] Connection refused

This occurs before the debuggee starts and without an IDE or debugger client involved.

It occurs deterministically when either networkingMode=VirtioProxy or hostAddressLoopback=true is enabled in %UserProfile%\.wslconfig. Both settings independently trigger the problem.

Adding a time.sleep(0.2) immediately before the following line in debugpy/adapter/__main__.py works around the issue:

sock.connect((localhost, args.for_server))

Expected behavior

debugpy.listen() should start normally under WSL2 with networkingMode=VirtioProxy and/or hostAddressLoopback=true enabled.

Steps to reproduce:

  1. In %UserProfile%\.wslconfig, enable either setting:

    [wsl2]
    networkingMode=VirtioProxy
    

    or:

    [experimental]
    hostAddressLoopback=true
    
  2. Apply the configuration from Windows PowerShell:

    wsl --shutdown
    
  3. Open WSL and run:

    uv run python -Xfrozen_modules=off -m debugpy \
      --listen 127.0.0.1:5678 \
      -c "import time; time.sleep(60)"
    
  4. Observe the immediate ConnectionRefusedError from the debugpy adapter.

  5. Disable the relevant .wslconfig setting, run wsl --shutdown, and repeat. The command succeeds.

Lingua principale
Python
Stelle
2.5k
Fork
202
Merge medio
5g 1h
PR unite (30g)
1

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/debugpy

Tutte le issue di microsoft/debugpy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.