WSL isn't working in VS code. What could be the problem here?

Hello I'm newbie using an Linux environment and VS code. I've used windows terminal to access on WSL2 and it worked well.

I'm trying to set up development environment but WSL isn't working in VS code. How can I fix the problem here? It keeps showing "VS Code Server for WSL closed unexpectedly." message.

[2020-12-03 07:24:35.010] Resolving wsl+docker-desktop, resolveAttempt: 1
[2020-12-03 07:24:35.106] Starting VS Code Server inside WSL (docker-desktop)
[2020-12-03 07:24:35.106] Extension version: 0.51.4, Windows build: 19041. Multi distro support: available. WSL path support: enabled
[2020-12-03 07:24:35.107] No shell environment set or found for current distro.
[2020-12-03 07:24:35.317] Probing if server is already installed: C:\WINDOWS\System32\wsl.exe -d docker-desktop -e sh -c "[ -d ~/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
[2020-12-03 07:24:37.900] Probing result: found
[2020-12-03 07:24:37.901] Server install found in WSL
[2020-12-03 07:24:37.901] Launching C:\WINDOWS\System32\wsl.exe -d docker-desktop sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" e5a624b788d92b8d34d1392e4c4d9789406efe8f stable .vscode-server 0  '}
[2020-12-03 07:24:38.017] Setting up server environment: Looking for /root/.vscode-server/server-env-setup. Not found.
[2020-12-03 07:24:38.017] WSL version: 4.19.128-microsoft-standard docker-desktop
[2020-12-03 07:24:38.017] WSL2-shell-PID: 11
[2020-12-03 07:24:38.017] Starting server: /root/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/server.sh  --port=0 --use-host-proxy --enable-remote-auto-shutdown 
[2020-12-03 07:24:38.018] /root/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/server.sh: line 12: /root/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/node: not found
[2020-12-03 07:24:38.018] VS Code Server for WSL closed unexpectedly.
[2020-12-03 07:24:38.018] For help with startup problems, go to
[2020-12-03 07:24:38.018] https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips
[2020-12-03 07:24:38.021] C:\WINDOWS\System32\wsl.exe -d docker-desktop -e kill 11
[2020-12-03 07:24:38.171] WSL Daemon exited with code 0

I encountered the same problem, but it was solved by restarting the WSL2 distribution. I'm using Ubuntu-20.04, so I rebooted with the following command. After reboot, reopen VS Code and hopefully your problem will be solved.

wsl -t Ubuntu-20.04

  1. In Vs Code ctrl+schift+p
  2. Open Preferences: Open Settings (JSON)
  3. Add "terminal.integrated.shell.windows": "wsl.exe",
  4. Reopen terminal.

If you need to open a specific distribution, then additionally for example:

  1. "terminal.integrated.shellArgs.windows": ["-d", "Ubuntu-20.04"],
  2. Reopen terminal.