VS Code Server for WSL closed unexpectedly

Gustavo Gondim
GGondim
Published in
1 min readJul 20, 2020

--

I know there is a lot of answers for this generic problem around the web, but here is what I did to solve this problem.

🔍 Diagnostics

  • VS Code started and refused to connect to WSL. WSL terminal simply outputs “VS Code Server for WSL closed unexpectedly”.
  • WSL was accessible from Windows Command Prompt with wsl command.
  • Default distro was correctly set in Windows (checked with wsl -l command).
  • Default distro was correctly set in VSCode (checked with “New Window using Distro…” command).
  • Reboot did not solve the problem.
  • Disconnecting from WSL host + uninstalling and reinstalling the Remote extension did not solve the problem.

✔ The solution that worked for me

  • Inside a wsl prompt, I deleted the .vscode-server folder inside home directory using rm -rf ~/.vscode-server
  • Spawned a vscode from WSL using code ~ , which caused a reinstall of VS Code Remote

Then it worked 🤷‍♂️

⚠ Warning! This solution removes all the installed extensions in the host

If you want to maintain the installed host extensions, make a backup before deleting .vscode-server directory, and then copy all the extensions again.

  • Backup using mv ~/.vscode-server ~/.vscode-server-bkp
  • After fixing the problem, close VS Code then copy back all the files again using rm -rf ~/.vscode-server/extensions; mv ~/.vscode-server-bkp/extensions ~/.vscode-server/extensions

This is not a post intended to provide support, please don’t ask about your problem in comments. Use vscode GitHub issues instead.

--

--

Gustavo Gondim
GGondim

Produtos digitais e tecnologia ∴ Diretor @Eletromidia | Cofundador @NOALVO