Skip to content

Port Forwarding Fails to reconnect after disconnect with useLocalServer true #10916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
6 tasks done
sidewinder12s opened this issue Apr 30, 2025 · 1 comment
Open
6 tasks done
Assignees
Labels
ssh Issue in vscode-remote SSH

Comments

@sidewinder12s
Copy link

Is there an existing issue for this bug?

  • I have searched the existing open issues and found none that apply.
  • If I find any issue of interest that is related or closed, I will included a link to it in this issue.

Required Troubleshooting Steps

  • I have read and performed the troubleshooting steps
  • I have tried both values of the remote.SSH.useLocalServer setting
  • My issue was not covered in the Tips and Tricks linked from the Troubleshooting Wiki.
  • I will include a complete copy of my Remote - SSH logs by running Remote-SSH: Show Log in the command palette or from View > Output in the menu bar

[Optional] Diagnose with Copilot

I did not ask the @remote-ssh participant for help

In step 2 of the troubleshooting wiki, what was the result of running the generated SSH command verbatim outside of VS Code?

I did not try step 2 of the troubleshooting steps

Remote-SSH Log

Not available

Expected Behavior

vscode should reconnect

Actual Behavior

Port Forwarding fails

Steps To Reproduce

  1. MacOS
  2. Connect to remote host with standard settings
  3. Disconnect/let laptop sleep/disconnect network
  4. Attempt to reconnect and/or reload vscode window
  5. Port Forwarding fails

Anything else?

Here are the vscode connection logs, the Remote - SSH logs do not seem to be available due to where this fails:

[08:31:10.558] Log Level: 2
[08:31:10.591] VS Code version: 1.99.3
[08:31:10.591] Remote-SSH version: [email protected]
[08:31:10.592] darwin arm64
[08:31:10.717] SSH Resolver called for "ssh-remote+vdesk", attempt 1
[08:31:10.720] remote.SSH.useLocalServer = true
[08:31:10.721] remote.SSH.useExecServer = true
[08:31:10.721] remote.SSH.bindHost = {}
[08:31:10.721] remote.SSH.path = undefined
[08:31:10.721] remote.SSH.configFile = undefined
[08:31:10.722] remote.SSH.useFlock = true
[08:31:10.722] remote.SSH.lockfilesInTmp = false
[08:31:10.722] remote.SSH.localServerDownload = auto
[08:31:10.722] remote.SSH.remoteServerListenOnSocket = false
[08:31:10.723] remote.SSH.defaultExtensions = []
[08:31:10.723] remote.SSH.defaultExtensionsIfInstalledLocally = []
[08:31:10.723] remote.SSH.loglevel = 2
[08:31:10.729] remote.SSH.enableDynamicForwarding = true
[08:31:10.729] remote.SSH.enableRemoteCommand = false
[08:31:10.729] remote.SSH.serverPickPortsFromRange = {}
[08:31:10.729] remote.SSH.serverInstallPath = {}
[08:31:10.730] remote.SSH.permitPtyAllocation = false
[08:31:10.730] remote.SSH.preferredLocalPortRange = undefined
[08:31:10.730] remote.SSH.useCurlAndWgetConfigurationFiles = false
[08:31:10.730] remote.SSH.experimental.chat = false
[08:31:10.731] remote.SSH.experimental.enhancedSessionLogs = false
[08:31:10.731] remote.SSH.httpProxy = {}
[08:31:10.731] remote.SSH.httpsProxy = {}
[08:31:15.069] SSH Resolver called for host: vdesk
[08:31:15.069] Setting up SSH remote "vdesk"
[08:31:15.075] Acquiring local install lock: /var/folders/2f/z76z3bbd11b6jgz5tpl9tcn00000gq/T/vscode-remote-ssh-cd44a69c-install.lock
[08:31:15.082] Looking for existing server data file at /Users/geoffwebster/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-cd44a69c-17baf841131aa23349f217ca7c570c76ee87b957-0.119.0-es/data.json
[08:31:15.083] No existing data file
[08:31:15.084] Using commit id "17baf841131aa23349f217ca7c570c76ee87b957" and quality "stable" for server
[08:31:15.084] Extensions to install: 
[08:31:15.089] Install and start server if needed
[08:31:19.044] PATH: /Users/geoffwebster/.krew/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/usr/local/go/bin:/Users/geoffwebster/.oh-my-zsh/custom/plugins/git-extra-commands/bin
[08:31:19.044] Checking ssh with "ssh -V"
[08:31:19.055] > OpenSSH_9.9p1, LibreSSL 3.3.6

[08:31:23.012] askpass server listening on /var/folders/2f/z76z3bbd11b6jgz5tpl9tcn00000gq/T/vscode-ssh-askpass-2a2e3cffb3f17c9134c7e03ec9852ded98c32192.sock
[08:31:23.013] Spawning local server with {"serverId":1,"ipcHandlePath":"/var/folders/2f/z76z3bbd11b6jgz5tpl9tcn00000gq/T/vscode-ssh-askpass-56d0cf2ebc5fd6e0f65c95298b398cef9444bc9f.sock","sshCommand":"ssh","sshArgs":["-v","-T","-D","59633","-o","ConnectTimeout=15","vdesk","bash"],"serverDataFolderName":".vscode-server","dataFilePath":"/Users/geoffwebster/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-cd44a69c-17baf841131aa23349f217ca7c570c76ee87b957-0.119.0-es/data.json"}
[08:31:23.013] Local server env: {"SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.2kQc1pVNzg/Listeners","SHELL":"/bin/zsh","DISPLAY":"1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"/Users/geoffwebster/.vscode/extensions/ms-vscode-remote.remote-ssh-0.119.0/out/local-server/askpass.sh","VSCODE_SSH_ASKPASS_NODE":"/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin)","VSCODE_SSH_ASKPASS_EXTRA_ARGS":"","VSCODE_SSH_ASKPASS_MAIN":"/Users/geoffwebster/.vscode/extensions/ms-vscode-remote.remote-ssh-0.119.0/out/askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"/var/folders/2f/z76z3bbd11b6jgz5tpl9tcn00000gq/T/vscode-ssh-askpass-2a2e3cffb3f17c9134c7e03ec9852ded98c32192.sock"}
[08:31:23.014] Spawned 64438
[08:31:23.015] Using connect timeout of 17 seconds
[08:31:23.137] > local-server-1> Running ssh connection command: ssh -v -T -D 59633 -o ConnectTimeout=15 vdesk bash
[08:31:23.139] > local-server-1> Spawned ssh, pid=64444
[08:31:23.148] stderr> OpenSSH_9.9p1, LibreSSL 3.3.6
OMIT Host Details
[08:31:28.684] > Linux 6.8.0-1027-aws #29~22.04.1-Ubuntu SMP Sun Mar 30 07:45:38 UTC 2025
[08:31:28.684] Platform: linux
[08:31:28.761] > /bin/bash
[08:31:28.762] Parent Shell: bash
[08:31:28.762] Parent Shell pid: 64438
[08:31:28.762] Waiting for subshell to start
[08:31:28.817] Waiting for subshell to start
[08:31:28.839] > 11105
[08:31:28.839] stdout -> '11105'
[08:31:28.839] sub-process detected
[08:31:28.893] > 11105
[08:31:28.915] > e5316b371331: running
> Script executing under PID: 11105
[08:31:28.924] > Found existing installation at /home/gwebster/.vscode-server...
> Starting VS Code CLI...
[08:31:28.925] > Removing old logfile at /home/gwebster/.vscode-server/.cli.17baf841131aa23349f217ca7c570c76ee87b957.log
[08:31:28.927] > Spawned remote CLI: 11123
[08:31:28.930] > Waiting for server log...
[08:31:28.966] > e5316b371331: start
> listeningOn==127.0.0.1:34845==
> osReleaseId==ubuntu==
> arch==x86_64==
> vscodeArch==x64==
> bitness==64==
> tmpDir==/run/user/1551==
> platform==linux==
> unpackResult====
> didLocalDownload==0==
> downloadTime====
> installTime====
> serverStartTime==39==
> execServerToken==111a1aa1-1aaa-111a-aa11-1aaa11111a11==
> platformDownloadPath==cli-alpine-x64==
> SSH_AUTH_SOCK==/tmp/ssh-XXXX4yfhi5/agent.11102==
> DISPLAY====
> e5316b371331: end
[08:31:28.966] Received install output: 
listeningOn==127.0.0.1:34845==
osReleaseId==ubuntu==
arch==x86_64==
vscodeArch==x64==
bitness==64==
tmpDir==/run/user/1551==
platform==linux==
unpackResult====
didLocalDownload==0==
downloadTime====
installTime====
serverStartTime==39==
execServerToken==111a1aa1-1aaa-111a-aa11-1aaa11111a11==
platformDownloadPath==cli-alpine-x64==
SSH_AUTH_SOCK==/tmp/ssh-XXXX4yfhi5/agent.11102==
DISPLAY====

[08:31:28.967] Remote server is listening on port 34845
[08:31:28.967] Parsed server configuration: {"serverConfiguration":{"remoteListeningOn":{"port":34845},"osReleaseId":"ubuntu","arch":"x86_64","sshAuthSock":"/tmp/ssh-XXXX4yfhi5/agent.11102","display":"","tmpDir":"/run/user/1551","platform":"linux","execServerToken":"111a1aa1-1aaa-111a-aa11-1aaa11111a11"},"serverStartTime":39,"installUnpackCode":""}
[08:31:28.971] Persisting server connection details to /Users/geoffwebster/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-cd44a69c-17baf841131aa23349f217ca7c570c76ee87b957-0.119.0-es/data.json
[08:31:32.865] Starting forwarding server. local port 59640 -> socksPort 59633 -> remotePort 34845
[08:31:32.866] Forwarding server listening on port 59640
[08:31:32.866] Waiting for ssh tunnel to be ready
[08:31:32.868] Server delay-shutdown request failed: write EPIPE
[08:31:32.869] > local-server-1> Timed out
[08:31:32.869] [Forwarding server port 59640] Got connection 0
[08:31:32.870] Tunneled port 34845 to local port 59640
[08:31:32.870] Resolved "ssh-remote+vdesk" to "port 59640"
[08:31:32.876] Initizing new exec server for ssh-remote+vdesk
[08:31:32.876] Resolving exec server at port 59640
[08:31:32.876] Local server exit: 0
[08:31:32.879] [Forwarding server port 59640] Got connection 1
[08:31:32.880] Failed to set up socket for dynamic port forward to remote port 34845: connect ECONNREFUSED 127.0.0.1:59633. TCP port forwarding may be disabled, or the remote server may have crashed. See the VS Code Server log above for details.
[08:31:32.883] Failed to set up socket for dynamic port forward to remote port 34845: connect ECONNREFUSED 127.0.0.1:59633. TCP port forwarding may be disabled, or the remote server may have crashed. See the VS Code Server log above for details.

Setting useLocalServer: false seems to work. useExecServer also does not seem to have an effect

@sidewinder12s sidewinder12s added the ssh Issue in vscode-remote SSH label Apr 30, 2025
@sidewinder12s sidewinder12s changed the title Port Forwarding Fails after recoonect after disconnect with useLocalServer Port Forwarding Fails to reconnect after disconnect with useLocalServer true Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ssh Issue in vscode-remote SSH
Projects
None yet
Development

No branches or pull requests

3 participants
@sidewinder12s @joshspicer and others