Adapter bootstrap fails with ConnectionRefusedError on WSL2 VirtioProxy or hostAddressLoopback
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- devtools, networking
Research direction
Start in debugpy/adapter/main.py at the adapter's sock.connect((localhost, args.for_server)) call, then reproduce with the provided uv run command under WSL2. Compare behavior with networkingMode=VirtioProxy and hostAddressLoopback=true enabled or disabled; done means debugpy.listen() starts without ConnectionRefusedError under the affected settings.
Written by the indexing model from the issue text.
Description
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:
-
In
%UserProfile%\.wslconfig, enable either setting:[wsl2] networkingMode=VirtioProxyor:
[experimental] hostAddressLoopback=true -
Apply the configuration from Windows PowerShell:
wsl --shutdown -
Open WSL and run:
uv run python -Xfrozen_modules=off -m debugpy \ --listen 127.0.0.1:5678 \ -c "import time; time.sleep(60)" -
Observe the immediate
ConnectionRefusedErrorfrom the debugpy adapter. -
Disable the relevant
.wslconfigsetting, runwsl --shutdown, and repeat. The command succeeds.
- Dominant language
- Python
- Stars
- 2.5k
- Forks
- 202
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/debugpy
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
All issues in microsoft/debugpy
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100