Constantly losing WSL connection
- VSCode Version: 1.53.2
- Local OS Version: Windows 10 pro insider preview 21318
- Remote OS Version: Ubuntu 20.04 LTS
- Remote Extension/Connection Type: WSL2
Steps to Reproduce:
- open vscode in wsl2 via code . on mounted drive
- open a notebook *.ipynb
- wait till it loses connection and tries to reconnect forever
- the mount is now offline till I restart windows
Does this issue occur when you try this locally?: Yes Does this issue occur when you try this locally and all extensions are disabled?: don't know how to disable them I only have basic once
Thanks for reporting @mdeberts. Did this just start happening recently, or has it been happening for a while/always happened? Can you share any log output when it occurs?
I have been facing a similar issue while developing with WSL2 + VS Code + Remote Extension. I came here looking to see if I was the only one and found this.
Below is a snippet of my most recent log, but it's been continually happening. Sometimes I have to restart my PC. A few nights ago it actually crashed my Windows Audio + Video drivers and I had to re-install them.
[2021-02-26 13:48:32.967] [renderer1] [info] [remote-connection][ExtensionHost][3a67d…][reconnect] starting reconnecting loop. You can get more information with the trace log level.
[2021-02-26 13:48:32.967] [renderer1] [info] [remote-connection][ExtensionHost][3a67d…][reconnect] resolving connection...
[2021-02-26 13:48:32.968] [renderer1] [info] [remote-connection][ExtensionHost][3a67d…][reconnect] connecting to 172.27.22.16:33813...
[2021-02-26 13:48:33.039] [renderer1] [info] [remote-connection][ExtensionHost][3a67d…][reconnect] reconnected!
[2021-02-26 14:03:26.667] [renderer1] [error] getaddrinfo ENOTFOUND default.exp-tas.com: Error: getaddrinfo ENOTFOUND default.exp-tas.com
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)
[2021-02-26 14:12:11.321] [renderer1] [warning] {}
[2021-02-26 14:12:21.743] [renderer1] [info] [remote-connection][ExtensionHost][3a67d…][reconnect] starting reconnecting loop. You can get more information with the trace log level.
[2021-02-26 14:12:21.743] [renderer1] [info] [remote-connection][ExtensionHost][3a67d…][reconnect] resolving connection...
[2021-02-26 14:12:21.743] [renderer1] [info] [remote-connection][ExtensionHost][3a67d…][reconnect] connecting to 172.27.22.16:33813...
[2021-02-26 14:12:31.327] [renderer1] [info] [remote-connection][Management ][45649…][reconnect] starting reconnecting loop. You can get more information with the trace log level.
[2021-02-26 14:12:31.329] [renderer1] [info] [remote-connection][Management ][45649…][reconnect] resolving connection...
[2021-02-26 14:12:31.342] [renderer1] [info] [remote-connection][Management ][45649…][reconnect] connecting to 172.27.22.16:33813...
[2021-02-26 14:12:34.036] [renderer1] [info] [remote-connection][ExtensionHost][3a67d…][reconnect] reconnected!
[2021-02-26 14:12:34.061] [renderer1] [info] [remote-connection][Management ][45649…][reconnect] reconnected!
You can get more information with the trace log level.
Would you be able to provide the trace-level telemetry @anthonyalayo? Also, does setting "workbench.enableExperiments" to false change anything?
@bamurtaugh I'd love to -- I've actually been looking for instructions on something of the sort so that I can provide some useful debug info. Is there a guide to setting trace log level?
Also, does setting "workbench.enableExperiments" to false change anything?
I'll try that as well and update if I see any disconnects.
@bamurtaugh tried it with the experiments disabled, still happening unfortunately.
Thanks for the update @anthonyalayo - you can set trace-level logging through the commands: Developer: Set Log Level -> Trace.
Alright I think I figured it out on my side. I believe for me, the issue is due to WSL2 running out of memory.
After noticing that Windows Terminal is bonked once VS Code loses connection, I started looking into that direction. I have been using a .wslconfig as WSL2 combined with Docker Desktop can eat all of your memory if you don't limit it. Increasing my .wslconfig memory size has stopped the hangs/crashes/disconnects.
@bamurtaugh does VS Code utilize memory inside WSL2 when using the remote plugin? Or does it use memory from Windows outside of WSL2?
@mdeberts if you try to open another terminal window for your WSL2 distro after the reconnect loop happens, does it load or does it hang?
@aeschli Does it sound like this could be a memory consumption issue?
The remote server runs insider WSL, so yes, it consumes WSL memory.
Thanks @aeschli and @bamurtaugh. Is there steps we can follow to see how much memory is being used? That could make any of these issues very easy to confirm that memory is indeed the issue.
Try top to see which process uses what amount of memory.
@aeschli perhaps do you mean top? I cannot find a binary named tap.
I tried out top, but I couldn't find any real useful details:
~ top -c -n 1 ✔ 04:15:14 PM
top - 16:15:14 up 7:07, 0 users, load average: 0.22, 0.16, 0.16
Tasks: 51 total, 1 running, 47 sleeping, 0 stopped, 3 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 5943.0 total, 494.9 free, 2642.1 used, 2806.0 buff/cache
MiB Swap: 0.0 total, 0.0 free, 0.0 used. 2926.8 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 1276 968 524 S 0.0 0.0 0:01.03 /init
144 root 20 0 900 80 20 S 0.0 0.0 0:00.00 /init
145 root 20 0 900 88 20 S 0.0 0.0 0:00.00 /init
146 aalayo 20 0 764524 43352 28296 S 0.0 0.7 0:01.90 docker serve --address unix:///home/aalayo/.docker/run/docker-cli-api.sock
147 root 20 0 0 0 0 Z 0.0 0.0 0:00.00 [init] <defunct>
153 root 20 0 900 88 20 S 0.0 0.0 0:00.01 /init
154 root 20 0 1538108 28752 14672 S 0.0 0.5 0:01.95 /mnt/wsl/docker-desktop/docker-desktop-proxy --distro-name Ubuntu --docker-desktop-root /mnt/wsl/docker-desktop --use-cloud-cli=true
184 root 20 0 1256 352 20 S 0.0 0.0 0:00.00 /init
185 root 20 0 1256 360 20 S 0.0 0.0 0:00.02 /init
186 aalayo 20 0 19916 13672 4660 S 0.0 0.2 0:02.41 -zsh
669 aalayo 20 0 14496 5908 1932 S 0.0 0.1 0:00.00 -zsh
670 aalayo 20 0 14480 3960 0 S 0.0 0.1 0:00.22 -zsh
673 aalayo 20 0 14716 6032 1940 S 0.0 0.1 0:00.00 -zsh
I also tried htop which did list me a lot of VS Code processes, but that's where I hit the next issue. Since there are many PIDs associated with VS Code, it's not possible upon inspection to find out the total memory usage and which PIDs are relevant.
Could you point me to a command that would help out here? This would help diagnose the OOM issue and also give developers a minimum memory requirement to make sure we meet when using VS Code Remote.
Thanks!
Yes, top, sorry for the typo
Great thanks @aeschli , please see the rest of my reply above.
Sorry, I don't have any additional insights. The memory usage of the VSCode server depends on what you do with it. How many remote windows you have open, how many language servers you run, what kind of language server, how big the workspace is.
https://superuser.com/questions/866007/memory-usage-grouped-by-parent-process has some tips on how to group memory usage per parent process.
Thanks @aeschli, I'll try that out. Regardless it looks like the answer here is to increase your allocated WSL memory and see if that fixes chronic disconnect loops. I'm alright with that approach, it solved the issue my side.
Not sure if @mdeberts is still around to test this and/or comment/close but it's resolved for me.
Hi, I have my WSL memory set to 12 gb and still have chronic disconnect loops:

VS Code works for 1-2 minutes and then all extensions just stop working and I have to reconnect to WSL.
I've been experimenting same issue in the same context as before explained VS Code in Windows 11 Home version 22H2 WSL remote connection recently the information in the screenshot has appeared. the issue appeared after last windows actualization
Last error log:
[2023-11-07 14:18:24.995] Extension version: 0.81.8 [2023-11-07 14:18:25.013] L10N bundle: undefined [2023-11-07 14:18:25.052] authorityHierarchy: wsl+ubuntu [2023-11-07 14:18:25.052] WSL extension activating for a local WSL instance [2023-11-07 14:18:25.140] Resolving wsl+ubuntu, resolveAttempt: 1 [2023-11-07 14:18:25.142] NodeExecServer run: C:\WINDOWS\System32\wsl.exe --status [2023-11-07 14:18:25.805] WSL feature installed: true (wsl --status) [2023-11-07 14:18:25.806] NodeExecServer run: C:\WINDOWS\System32\wsl.exe --list --verbose [2023-11-07 14:18:26.268] 3 distros found [2023-11-07 14:18:26.270] Starting VS Code Server inside WSL (wsl2) [2023-11-07 14:18:26.270] Windows build: 22621. Multi distro support: available. WSL path support: enabled [2023-11-07 14:18:26.270] Scriptless setup: false [2023-11-07 14:18:26.270] No shell environment set or found for current distro. [2023-11-07 14:18:26.741] WSL daemon log file: [2023-11-07 14:18:26.751] Probing if server is already installed: if [ -d ~/.vscode-server/bin/2b35e1e6d88f1ce073683991d1eff5284a32690f ]; then printf 'install-found '; fi; if [ -f /etc/alpine-release ]; then printf alpine-; fi; uname -m [2023-11-07 14:18:26.754] NodeExecServer run: C:\WINDOWS\System32\wsl.exe -d Ubuntu -e sh -c if [ -d ~/.vscode-server/bin/2b35e1e6d88f1ce073683991d1eff5284a32690f ]; then printf 'install-found '; fi; if [ -f /etc/alpine-release ]; then printf alpine-; fi; uname -m [2023-11-07 14:19:32.894] Unable to detect if server is already installed: Error: Failed to probe if server is already installed: code: Failed to probe if server is already installed: code: 4294967295, , Se produjo un error durante el intento de conexion ya que la parte conectada no respondio adecuadamente tras un periodo de tiempo, o bien se produjo un error en la conexion establecida ya que el host conectado no ha podido responder. [2023-11-07 14:19:32.894] Error code: Wsl/Service/0x8007274c [2023-11-07 14:19:32.894] [2023-11-07 14:19:32.896] NodeExecServer run: C:\WINDOWS\System32\wsl.exe -d Ubuntu sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" 2b35e1e6d88f1ce073683991d1eff5284a32690f stable code-server .vscode-server --host=127.0.0.1 --port=0 --connection-token=1470249766-413960315-4125438696-2745987126 --use-host-proxy --without-browser-env-var --disable-websocket-compression --accept-server-license-terms --telemetry-level=all' [2023-11-07 14:20:03.242] Se produjo un error durante el intento de conexi�n ya que la parte conectada no respondi� adecuadamente tras un periodo de tiempo, o bien se produjo un error en la conexi�n establecida ya que el host conectado no ha podido responder. [2023-11-07 14:20:03.242] Error code: Wsl/Service/0x8007274c [2023-11-07 14:20:03.242] [2023-11-07 14:20:03.244] For help with startup problems, go to https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips
@ruteru https://github.com/microsoft/WSL/issues/9852 is about 'Error code: Wsl/Service/0x8007274c'
I have the same problem on my end. Happens multiple times every day on one of my computers. Clicking "Reload Window" usually works.
Got same issue.
Wsl/Service/0x8007274c
Version: 1.99.0-insider (user setup)
Electron: 34.2.0
ElectronBuildId: 11044223
Chromium: 132.0.6834.196
Node.js: 20.18.2
V8: 13.2.152.36-electron.0
Betriebssystem: Windows_NT x64 10.0.26100
Similar unsolved issues:
- https://github.com/microsoft/WSL/issues/9852
- https://github.com/microsoft/WSL/issues/11612
- https://github.com/microsoft/WSL/issues/9832
- https://github.com/microsoft/WSL/issues/10174
I'm having this issue fairly often and it seems to be getting more frequent - multiple times a day now.
Clicking 'Reconnect Now' or 'Reload Window' doesn't work for me.
When it occurs I see my Windows Terminal ubuntu sessions disconnect with message:
[process exited with code 1 (0x00000001)]
You can now close this terminal with Ctrl+D, or press Enter to restart.
To get it working again, I have to close every instance of VS Code and Windows Terminal.
Same issue here: VS Code losing connection to WSL.
-
htoppoints to a .vscode-servernodeinstance with 31GB of VIRT ! -
VS Code with WSL2 Ubuntu:
-
uname -a: Linux 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux -
Using the rust-analyzer extension, with a large Rust project with many dependencies (memory hog). I have already increased the memory, swap and reduced swappiness, because of 100% disk usage
-
.wslconfig:
# Settings apply across all Linux distros running on WSL 2
[wsl2]
processors=18
# Sets amount of swap storage space to _ GB, default is 25% of available RAM
swap=10485760000
# Limits VM memory to use no more than _ GB, this can be set as whole numbers using GB or MB
memory=11534336000
# Avoid 100% disk usage
# https://github.com/microsoft/WSL/issues/9383
kernelCommandLine="sysctl.vm.swappiness=10"
# Enable experimental features
[experimental]
sparseVhd=true
autoMemoryReclaim=gradual
UPDATE
Reinstalled WSL, VS Code from scratch. Removed Docker Desktop.
VS Code still drops connection to WSL with error message:
File system provider for vscode-remote://wsl%2Bubuntu/home/johncd/linuxcode/rust_howto/.devcontainer/install_deps.sh is not available.
(that was the file I was editing)
VS Code terminal not responsive.
Had to restart VS Code to reconnect.
wsl --version
WSL version: 2.4.13.0 Kernel version: 5.15.167.4-1 WSLg version: 1.0.65 MSRDC version: 1.2.5716 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.26100.1-240331-1435.ge-release Windows version: 10.0.26100.3476
^ Update of the update: disabling Auto memory reclaim in WSL settings seems to help.
Also happening to me constantly. Sometimes I have to reboot VsCode 10+ times before it stops, and I haven't been able to figure out why or what is causing it yet.
Update: Uninstalling all my extensions fixes it. There must be at least one of them causing some conflict somewhere, just hard to pinpoint it.
^ Update of the update: disabling Auto memory reclaim in WSL settings seems to help.
It seems that setting autoMemoryReclaim=disabled and restarting WSL did not do the trick. As soon as multiple vscode windows are open in WSL mode, issue returns after a short while. Noticed that when switched to vscode window after doing a git push.
I'm facing the same issue, and here is my setup:
- Two WSL2 distros running
- Docker Desktop with WSL integration enabled
- Two VS Code windows (each connected to a different WSL2 distro)
With this setup, everything works well except that VS Code occasionally loses connection to the WSL2 distro. (And this is really unfortunate)
I'll come back with more details as soon as I can capture them or if I run into the issue again. Hopefully I can find some logs or some clue.
I am facing the same issue. Whenever i made a minor change in code or even try to install dependencies vs code connection to wsl get losts . Then shows to option to either reload window or reconnect now and none of them works .
It happens to me often when the laptop comes back from hibernate.