The first time I run VSCode from WSL after a reboot it works fine but if I have to launch again, it fails to connect "Failed to connect to the remote extension host server (Error: handshake timeout)". I have not been able to fix this without rebooting my host
Steps to Reproduce:
code-insiders . code-insiders .
Does this issue occur when all extensions are disabled?: Yes
Found the issue. Both the VS code extension package and the app I was developing want to listen on port 8000. I'm honestly not sure why I'm able to start and use the app while VScode is already running if the port is bound but it works until I try to restart vscode while the app is running. VS code asks my app for a websocket and my browser asks vscode extension for my app. Super confusing.
Would love to see better documentation that the WSL integration is opening a port and which one it uses. Would also like to see a more informative error message here. or a way to get to the remote connection logs from the error message toast. (I figured this out because I was able to hit the Details link quick enough during set up before it failed)
If you open the WSL log (use the remote indicator in the status bar), you can see which port is used.
It's not a fixed port, but we probe which port is free and pick it. 8000 is the default, but maybe we should have a different, more uncommon default or even make this configurable.
Yes I would advocate for at least using a more uncommon port. 8000 is the default for Django and very common for any local web development (8080, 8000, etc).
If it's supposed to be probing for an open port, it's not doing that for me, nor does it even seem like its really binding the port it uses because if I run Django second, it has no problem listening on a port that VS code claims to be using and if I run VS code second, it attempts to listen on a port Django as already bound and does not try to find a new port.
Not sure if this is related (if not I can open a separate issue), but I am having a similar issue with the default port of 8000 being used but already used by another process on my laptop. However, this issue only started for me with version 0.35.0 of Remote-WSL.
Version 0.34.0 of Remote-WSL still chooses a random unused port:
[2019-05-16 15:27:23.385] Starting VS Code Server inside WSL.
[2019-05-16 15:27:23.807] Launching C:\WINDOWS\System32\wsl.exe bash -i -c "./scripts/wslServer.sh e83e24a0c9225becd7341e56952177a20d5d4629 insider .vscode-remote " in c:\Users\e5554787.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.34.0
[2019-05-16 15:27:26.206] Remote configuration data at /home/mhein/.vscode-remote
[2019-05-16 15:27:26.206]
[2019-05-16 15:27:26.207]
[2019-05-16 15:27:26.207] *
[2019-05-16 15:27:26.207] * Visual Studio Code Server
[2019-05-16 15:27:26.207] *
[2019-05-16 15:27:26.207] * Reminder: You may only use this software with Visual Studio family products,
[2019-05-16 15:27:26.207] * as described in the license https://aka.ms/vscode-remote/license
[2019-05-16 15:27:26.207] *
[2019-05-16 15:27:26.207]
[2019-05-16 15:27:26.207]
[2019-05-16 15:27:26.207] IP Address: 168.162.76.127
[2019-05-16 15:27:26.207] IP Address: 192.168.33.1
[2019-05-16 15:27:26.207] IP Address: 10.42.0.1
[2019-05-16 15:27:26.207] IP Address: 192.168.34.1
[2019-05-16 15:27:26.207] Extension host agent listening on 61656
[2019-05-16 15:27:26.214] WSL resolver response: localhost:61656
I upgrade the extension to 0.35.0, it tries port 8000:
[2019-05-16 15:34:36.094] Launching C:\WINDOWS\System32\wsl.exe bash -c "./scripts/wslServer.sh e83e24a0c9225becd7341e56952177a20d5d4629 insider .vscode-remote " in c:\Users\e5554787.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.35.0
[2019-05-16 15:34:37.891] Updating server...
[2019-05-16 15:34:37.892] Starting server...
[2019-05-16 15:34:38.793] Remote configuration data at /home/mhein/.vscode-remote
[2019-05-16 15:34:38.793]
[2019-05-16 15:34:38.793]
[2019-05-16 15:34:38.793] *
[2019-05-16 15:34:38.793] * Visual Studio Code Server
[2019-05-16 15:34:38.793] *
[2019-05-16 15:34:38.793] * Reminder: You may only use this software with Visual Studio family products,
[2019-05-16 15:34:38.793] * as described in the license https://aka.ms/vscode-remote/license
[2019-05-16 15:34:38.793] *
[2019-05-16 15:34:38.793]
[2019-05-16 15:34:38.793]
[2019-05-16 15:34:38.793] IP Address: 168.162.76.127
[2019-05-16 15:34:38.794] IP Address: 192.168.33.1
[2019-05-16 15:34:38.794] IP Address: 10.42.0.1
[2019-05-16 15:34:38.794] IP Address: 192.168.34.1
[2019-05-16 15:34:38.794] Error occurred in server
[2019-05-16 15:34:38.794] { Error: listen EACCES 0.0.0.0:8000
[2019-05-16 15:34:38.794] at Server.setupListenHandle [as _listen2] (net.js:1313:19)
[2019-05-16 15:34:38.794] at listenInCluster (net.js:1378:12)
[2019-05-16 15:34:38.794] at Server.listen (net.js:1466:7)
[2019-05-16 15:34:38.794] at T._start (/home/mhein/.vscode-remote/bin/e83e24a0c9225becd7341e56952177a20d5d4629/out/vs/agent/remoteExtensionHostAgent.js:373:582)
[2019-05-16 15:34:38.794] at T.
[2019-05-16 15:34:38.794] at Generator.next (
[2019-05-16 15:34:38.794] at o (/home/mhein/.vscode-remote/bin/e83e24a0c9225becd7341e56952177a20d5d4629/out/vs/agent/remoteExtensionHostAgent.js:16:221)
[2019-05-16 15:34:38.794] at process._tickCallback (internal/process/next_tick.js:68:7)
[2019-05-16 15:34:38.794] errno: 'EACCES',
[2019-05-16 15:34:38.794] code: 'EACCES',
[2019-05-16 15:34:38.794] syscall: 'listen',
[2019-05-16 15:34:38.795] address: '0.0.0.0',
[2019-05-16 15:34:38.795] port: 8000 }
I rollback to 0.34.0:
[2019-05-16 15:38:23.498] Starting VS Code Server inside WSL.
[2019-05-16 15:38:23.931] Launching C:\WINDOWS\System32\wsl.exe bash -i -c "./scripts/wslServer.sh e83e24a0c9225becd7341e56952177a20d5d4629 insider .vscode-remote " in c:\Users\e5554787.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.34.0
[2019-05-16 15:38:26.029] Remote configuration data at /home/mhein/.vscode-remote
[2019-05-16 15:38:26.029]
[2019-05-16 15:38:26.029]
[2019-05-16 15:38:26.029] *
[2019-05-16 15:38:26.029] * Visual Studio Code Server
[2019-05-16 15:38:26.029] *
[2019-05-16 15:38:26.029] * Reminder: You may only use this software with Visual Studio family products,
[2019-05-16 15:38:26.029] * as described in the license https://aka.ms/vscode-remote/license
[2019-05-16 15:38:26.029] *
[2019-05-16 15:38:26.029]
[2019-05-16 15:38:26.029]
[2019-05-16 15:38:26.328] IP Address: 168.162.76.127
[2019-05-16 15:38:26.329] IP Address: 192.168.33.1
[2019-05-16 15:38:26.329] IP Address: 10.42.0.1
[2019-05-16 15:38:26.329] IP Address: 192.168.34.1
[2019-05-16 15:38:26.329] Extension host agent listening on 62008
[2019-05-16 15:38:26.335] WSL resolver response: localhost:62008
Defaulting to port 8000 has been caused by a bug in the startup script. Fix is on the way.
Glad to see a fix is on the way! Spent a while trying to figure out why going to my Django test app at "localhost:8000" was going to a "not found" page, turns out this is it! I went to see if I could configure the port manually for this in vscode settings for vscode-remote WSL and could not. The problem is that I have a bunch of automated scripts using the default Django 8000 port so it's awkward for me to reconfigure my entire setup in my app to work around this at the moment.
Is this resolved?
I'm having this issue on my work laptop that has port 8000 in use by some random corporate process and it's timing out.
Yes, that's fixed by the latest update of remote-wsl.
To verify this, open the WSL log when started up and check that the port picked is some random, unused port.
Most helpful comment
Yes I would advocate for at least using a more uncommon port. 8000 is the default for Django and very common for any local web development (8080, 8000, etc).
If it's supposed to be probing for an open port, it's not doing that for me, nor does it even seem like its really binding the port it uses because if I run Django second, it has no problem listening on a port that VS code claims to be using and if I run VS code second, it attempts to listen on a port Django as already bound and does not try to find a new port.