Intermittent connection problems between WSL and host machine
Windows Version
Microsoft Windows [Version 10.0.22621.5472]
WSL Version
2.5.7.0
Are you using WSL 1 or WSL 2?
- [x] WSL 2
- [ ] WSL 1
Kernel Version
6.6.87.1-microsoft-standard-WSL2
Distro Version
Ubuntu 24.04
Other Software
ms-vscode-remote.remote-wsl Version 0.99.0
Repro Steps
Use vscode or powershell to connect to WSL.
Expected Behavior
Continuous operation.
Actual Behavior
Connect to WSL using vscode, connects initially, after a few seconds it disconnects and is unable to re connect. For terminal connections I'm observing the same, wsl terminal works for a short period and then exits back to windows prompt. I have also observed an error after trying to connect to wsl in powershell:
Catastrophic failure
Error code: Wsl/Service/E_UNEXPECTED
When launching a node application in WSL it initially loads and listens to connections, but those are disconnected when the issue occurs.
WslLogs-2025-06-17_11-17-30.zip
Diagnostic Logs
No response
Diagnostic information
.wslconfig found
Detected appx version: 2.5.7.0
Detected user visible error: Wsl/Service/E_UNEXPECTED
Detected user visible error: Wsl/Service/E_UNEXPECTED
Detected user visible error: Wsl/Service/E_UNEXPECTED
Detected user visible error: Wsl/Service/E_UNEXPECTED
Detected user visible error: Wsl/Service/E_UNEXPECTED
Detected user visible error: Wsl/Service/E_UNEXPECTED
Detected user visible error: Wsl/Service/E_UNEXPECTED
Detected user visible error: Wsl/Service/E_UNEXPECTED
Detected user visible error: Wsl/Service/E_UNEXPECTED
Detected user visible error: Wsl/Service/E_UNEXPECTED
Thank you for reporting this @1265453673. Are you using docker by any chance ?
Also can you upgrade to 2.5.9 by running wsl --update --pre-release and check if the issue still exists with that version ?
Also can you upgrade to 2.5.9 by running
wsl --update --pre-releaseand check if the issue still exists with that version ?
Not using docker. I've already got the latest version installed.
The most recent version of Windows Subsystem for Linux is already installed.
It seems to occur mostly when running node programs, maybe memory related?
I've increased the memory head room which delays the crash, which leads me to think that WSL doesn't handle reaching this limit well in the newer version.
.wslconfig
[wsl2]
memory=16GB
processors=4
@OneBlue this issue still persists, do you need further information?
@1265453673: If you're not using docker, let's try to collect a full repro repro under log collection so we can understand what's going on. Can you please:
- Update WSL via
wsl --update --pre-release - run
wsl --shutdown - Start collecting /logs
- Reproduce the issue
- Share the log file on this issue
@OneBlue I've submitted the logs, after upgrading to version 2.6. It appears when the memory runs out on the machine, I still get the following error message: Catastrophic failure Error code: Wsl/Service/E_UNEXPECTED
Thank you @1265453673. Looking through the logs, I can see that the error is caused by a timeout when trying to create a new process. Let's try something. Can you please:
- Reproduce the issue
- While WSL is still running, open a debug shell via:
wsl --debug-shell - Paste the content of this script and share its output
That should help us understand what's going on inside the VM
Thank you @1265453673. Looking through the logs, I can see that the error is caused by a timeout when trying to create a new process. Let's try something. Can you please:
- Reproduce the issue
- While WSL is still running, open a debug shell via:
wsl --debug-shell- Paste the content of this script and share its output
That should help us understand what's going on inside the VM
Hi @OneBlue,
I launched the debug shell before the issue was reproduced, but the shell froze as it was reproduced. When trying to open another I was unable to create one.
PS > wsl --debug-shell
All pipe instances are busy.
Error code: Wsl/DebugShell/ERROR_PIPE_BUSY
PS > wsl
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Error code: Wsl/Service/0x8007274c
Thank you @1265453673. That's unfortunately expected. Only one debug shell can be connected per VM.
Could you share when the shell froze, and what the output was so far ?
Thank you @1265453673. That's unfortunately expected. Only one debug shell can be connected per VM.
Could you share when the shell froze, and what the output was so far ?
Is it possible to mount a persistent storage? I did have logs save before the crash but when the debug shell disappears so do the logs. Would it help to get logs before the issue occurs? - the issue seems to kill the instance making it difficult at the moment to get process logs.
@1265453673: Unfortunately, not easily. One thing you could do is (powershell):
curl.exe https://raw.githubusercontent.com/microsoft/WSL/refs/heads/master/diagnostics/dump-init.sh | wsl --debug-shell | Tee-Object -FilePath Output.txt
@1265453673: Unfortunately, not easily. One thing you could do is (powershell):
curl.exe https://raw.githubusercontent.com/microsoft/WSL/refs/heads/master/diagnostics/dump-init.sh | wsl --debug-shell | Tee-Object -FilePath Output.txt
Thanks that did extract the output. I ran it in powershell (administrator), hopefully it contains all you need. It was run just before total crash of the VM, I tried to run it again after but it didn't run probably because the VM is dead.
Actually it does still respond to the debug shell after the crash, here's its output.
Thank you @1265453673. Looking at the log I can se that the VM is running out of memory, which is most likely why it gets into a "broken" state.
You can probably fix this by increasing the amount of memory, or adding swap (or both).
By putting this in %USERPROFILE%/.wslconfig:
[wsl2]
memory=16GB
swap=16GB
Thanks for taking a look at the logs. Sounds like it is in fact an application issue.