WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Intermittent connection problems between WSL and host machine

Open 1265453673 opened this issue 6 months ago • 3 comments

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

1265453673 avatar Jun 17 '25 09:06 1265453673

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

github-actions[bot] avatar Jun 17 '25 09:06 github-actions[bot]

Thank you for reporting this @1265453673. Are you using docker by any chance ?

OneBlue avatar Jun 17 '25 20:06 OneBlue

Also can you upgrade to 2.5.9 by running wsl --update --pre-release and check if the issue still exists with that version ?

OneBlue avatar Jun 17 '25 20:06 OneBlue

Also can you upgrade to 2.5.9 by running wsl --update --pre-release and 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?

1265453673 avatar Jun 19 '25 14:06 1265453673

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

1265453673 avatar Jun 24 '25 10:06 1265453673

@OneBlue this issue still persists, do you need further information?

1265453673 avatar Jul 21 '25 11:07 1265453673

@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 avatar Jul 23 '25 17:07 OneBlue

@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

1265453673 avatar Jul 24 '25 08:07 1265453673

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

OneBlue avatar Jul 24 '25 18:07 OneBlue

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

1265453673 avatar Jul 28 '25 09:07 1265453673

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 ?

OneBlue avatar Jul 28 '25 17:07 OneBlue

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 avatar Jul 29 '25 07:07 1265453673

@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

OneBlue avatar Jul 30 '25 01:07 OneBlue

@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.

Output.txt

1265453673 avatar Jul 30 '25 08:07 1265453673

Actually it does still respond to the debug shell after the crash, here's its output.

OutputAfterCrash.txt

1265453673 avatar Jul 30 '25 08:07 1265453673

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

OneBlue avatar Jul 30 '25 18:07 OneBlue

Thanks for taking a look at the logs. Sounds like it is in fact an application issue.

1265453673 avatar Aug 01 '25 07:08 1265453673