Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vscode cannot connect to remote Linux (_WebSocket close with status code 1006)

Remote connection to Linux. After entering the password, there are two prompts on the right

11

And the terminal cannot input
The remote directory could not be loaded

I had tried countless times in many ways Reinstall vocode,delete ~/.vscode-server/ directory, and so on.
What the hell should I do.

22

like image 719
sytlq Avatar asked Aug 16 '21 08:08

sytlq


4 Answers

  1. Find out which instance of WSL is running
wsl -l --running
  1. Terminate all running instances of WSL
wsl --shutdown
  1. Then simply restart WSL
wsl 
like image 110
Basil Avatar answered Nov 10 '22 16:11

Basil


This can be resolved by rebooting the host machine (i.e. reboot your Windows PC) and restarting your WSL-2 box, then launching VSCode remote again.

No idea why this happens but from time to time I experience this issue.

Confirmed issue on:

Ubuntu 20.04
Vs code 1.60.1
like image 30
Garbit Avatar answered Nov 10 '22 16:11

Garbit


I changed the setting remote.WSL.server.connectThroughLocalhost (Settings -> Extensions -> Remote - WSL -> Connect Through Localhost) from disabled to enabled, and that fixed the issue for me.

No idea why this happened in the first place though, it was working fine without enabling this setting for over 2 months, and then suddenly it stopped working.

Maybe the IP of the virtual machine changed in some unexpected way?

like image 34
thnee Avatar answered Nov 10 '22 17:11

thnee


If anyone else comes across this question it's very easy.

  1. You're most likely using a reverse proxy
  2. Just enable websocket support on your reverse proxy.

Ex. If you are using Docker and the popular NGINX Proxy Manager; when you are adding a proxy host make sure to choose websocket support

No more 1006 error :)

like image 43
wildernessfamily Avatar answered Nov 10 '22 16:11

wildernessfamily