microsoft / microsoft/vscode-remote-release

Remote-SSH fails to recover from stale server metadata after system crash

Open
#11,538 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

ssh
Dominant language
Dockerfile
Stars
4.2k
Forks
469
Avg merge
1d 1h
Merged PRs (30d)
1

Description

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
Remote-SSH Log

[20:20:08.608] Log Level: 1
[20:20:08.616] SSH Resolver called for "ssh-remote+remote-dev-vm", attempt 1
[20:20:08.618] remote.SSH.useLocalServer = true
[20:20:08.618] remote.SSH.useExecServer = true
[20:20:08.618] remote.SSH.bindHost = {}
[20:20:08.618] remote.SSH.path = 
[20:20:08.618] remote.SSH.configFile = 
[20:20:08.618] remote.SSH.useFlock = true
[20:20:08.618] remote.SSH.lockfilesInTmp = false
[20:20:08.618] remote.SSH.localServerDownload = auto
[20:20:08.618] remote.SSH.remoteServerListenOnSocket = false
[20:20:08.618] remote.SSH.defaultExtensions = []
[20:20:08.618] remote.SSH.defaultExtensionsIfInstalledLocally = []
[20:20:08.618] remote.SSH.loglevel = 1
[20:20:08.618] remote.SSH.enableDynamicForwarding = true
[20:20:08.619] remote.SSH.enableRemoteCommand = false
[20:20:08.619] remote.SSH.serverPickPortsFromRange = {}
[20:20:08.619] remote.SSH.serverInstallPath = {}
[20:20:08.619] remote.SSH.permitPtyAllocation = false
[20:20:08.619] remote.SSH.preferredLocalPortRange = undefined
[20:20:08.619] remote.SSH.useCurlAndWgetConfigurationFiles = false
[20:20:08.619] remote.SSH.experimental.chat = false
[20:20:08.619] remote.SSH.experimental.enhancedSessionLogs = true
[20:20:08.619] remote.SSH.httpProxy = {"*":""}
[20:20:08.619] remote.SSH.httpsProxy = {"*":""}
[20:20:08.623] VS Code version: 1.111.0
[20:20:08.623] Remote-SSH version: remote-ssh@0.122.0
[20:20:08.623] darwin arm64
[20:20:08.624] Found relevant configuration for host remote-dev-vm in JSON data
[20:20:08.624] SSH Resolver called for host: remote-dev-vm
[20:20:08.624] Setting up SSH remote "remote-dev-vm"
[20:20:08.628] Acquiring local install lock: /var/folders/w5/c8plv88d1njcb7d012z7lbnh0000gn/T/vscode-remote-ssh-30ee4934-install.lock
[20:20:08.628] Looking for existing server data file at /Users/tsuna/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-30ee4934-ce099c1ed25d9eb3076c11e4a280f3eb52b4fbeb-0.122.0-es/data.json
[20:20:08.629] Found existing data file
[20:20:08.629] Found local server running: {"remoteListeningOn":{"port":38843},"osReleaseId":"ubuntu","arch":"x86_64","sshAuthSock":"/tmp/ssh-XXXXK68xZQ/agent.533212","tmpDir":"/run/user/5182","platform":"linux","execServerToken":"7231e650-3421-4138-bd62-7bcf665abb3c","pid":12788,"ipcHandlePath":"/var/folders/w5/c8plv88d1njcb7d012z7lbnh0000gn/T/vscode-ssh-askpass-73982050a6553b61d717e30791c0b1e83c65c116.sock","socksPort":57615,"startupTime":1773606109685}
[20:20:08.631] Server delay-shutdown request failed: connect ENOENT /var/folders/w5/c8plv88d1njcb7d012z7lbnh0000gn/T/vscode-ssh-askpass-73982050a6553b61d717e30791c0b1e83c65c116.sock
[20:20:08.632] Found running server - short-circuiting install
[20:20:08.632] Server delay-shutdown request failed: connect ENOENT /var/folders/w5/c8plv88d1njcb7d012z7lbnh0000gn/T/vscode-ssh-askpass-73982050a6553b61d717e30791c0b1e83c65c116.sock
[20:20:08.633] Starting forwarding server. local port 52025 -> socksPort 57615 -> remotePort 38843
[20:20:08.633] Forwarding server listening on port 52025
[20:20:08.633] Waiting for ssh tunnel to be ready
[20:20:08.633] Tunneled port 38843 to local port 52025
[20:20:08.633] Resolved "ssh-remote+remote-dev-vm" to "port 52025"
[20:20:08.636] Initizing new exec server for ssh-remote+remote-dev-vm
[20:20:08.636] Resolving exec server at port 52025
[20:20:08.637] [Forwarding server port 52025] Got connection 0
[20:20:08.637] [Forwarding server port 52025] Got connection 1
[20:20:08.639] Failed to set up socket for dynamic port forward to remote port 38843: connect ECONNREFUSED 127.0.0.1:57615. TCP port forwarding may be disabled, or the remote server may have crashed. See the VS Code Server log above for details.
[20:20:08.639] Failed to set up socket for dynamic port forward to remote port 38843: connect ECONNREFUSED 127.0.0.1:57615. TCP port forwarding may be disabled, or the remote server may have crashed. See the VS Code Server log above for details.
[20:20:10.634] Server delay-shutdown request failed: connect ENOENT /var/folders/w5/c8plv88d1njcb7d012z7lbnh0000gn/T/vscode-ssh-askpass-73982050a6553b61d717e30791c0b1e83c65c116.sock
[20:20:12.638] Server delay-shutdown request failed: connect ENOENT /var/folders/w5/c8plv88d1njcb7d012z7lbnh0000gn/T/vscode-ssh-askpass-73982050a6553b61d717e30791c0b1e83c65c116.sock
[20:20:14.641] Server delay-shutdown request failed: connect ENOENT /var/folders/w5/c8plv88d1njcb7d012z7lbnh0000gn/T/vscode-ssh-askpass-73982050a6553b61d717e30791c0b1e83c65c116.sock
[20:20:16.646] Server delay-shutdown request failed: connect ENOENT /var/folders/w5/c8plv88d1njcb7d012z7lbnh0000gn/T/vscode-ssh-askpass-73982050a6553b61d717e30791c0b1e83c65c116.sock
[20:20:18.650] Server delay-shutdown request failed: connect ENOENT /var/folders/w5/c8plv88d1njcb7d012z7lbnh0000gn/T/vscode-ssh-askpass-73982050a6553b61d717e30791c0b1e83c65c116.sock
[20:20:20.650] Server delay-shutdown request failed: connect ENOENT /var/folders/w5/c8plv88d1njcb7d012z7lbnh0000gn/T/vscode-ssh-askpass-73982050a6553b61d717e30791c0b1e83c65c116.sock
[20:20:22.655] Server delay-shutdown request failed: connect ENOENT /var/folders/w5/c8plv88d1njcb7d012z7lbnh0000gn/T/vscode-ssh-askpass-73982050a6553b61d717e30791c0b1e83c65c116.sock
[20:20:24.658] Server delay-shutdown request failed: connect ENOENT /var/folders/w5/c8plv88d1njcb7d012z7lbnh0000gn/T/vscode-ssh-askpass-73982050a6553b61d717e30791c0b1e83c65c116.sock
[20:20:26.664] Server delay-shutdown request failed: connect ENOENT /var/folders/w5/c8plv88d1njcb7d012z7lbnh0000gn/T/vscode-ssh-askpass-73982050a6553b61d717e30791c0b1e83c65c116.sock
[20:20:28.666] Server delay-shutdown request failed: connect ENOENT /var/folders/w5/c8plv88d1njcb7d012z7lbnh0000gn/T/vscode-ssh-askpass-73982050a6553b61d717e30791c0b1e83c65c116.sock
[20:20:30.670] Server delay-shutdown request failed: connect ENOENT /var/folders/w5/c8plv88d1njcb7d012z7lbnh0000gn/T/vscode-ssh-askpass-73982050a6553b61d717e30791c0b1e83c65c116.sock

Expected Behavior

Connecting to a remote host should work even if vscode was terminated uncleanly (e.g. due to a kernel panic)

Actual Behavior

Summary

After a kernel panic or system crash, VS Code Remote-SSH becomes unable to reconnect to remote hosts because it finds stale server metadata (data.json) and attempts to use non-existent IPC sockets and SOCKS ports. The built-in "Kill VS Code Server on Host" command also fails because it requires the same dead IPC socket to communicate.

Environment

Version: 1.111.0 (Universal)
Commit: ce099c1ed25d9eb3076c11e4a280f3eb52b4fbeb
Date: 2026-03-06T23:06:10Z
Electron: 39.6.0
ElectronBuildId: 13330601
Chromium: 142.0.7444.265
Node.js: 22.22.0
V8: 14.2.231.22-electron.0
OS: Darwin arm64 25.3.0

Remote-SSH extension version: 0.122.0

Steps to Reproduce

  1. Connect to a remote host via Remote-SSH
  2. Experience a kernel panic or force-kill VS Code ungracefully (simulating a crash, for example with a SIGKILL)
  3. Restart VS Code and attempt to reconnect to the same remote host
  4. Observe connection failure loop

Expected Behavior

VS Code should detect that the server metadata references dead processes/sockets and either:

  • Validate that the PID, SOCKS port, and IPC socket actually exist before "short-circuiting"
  • Automatically clean up stale metadata when validation fails
  • Establish a fresh connection when the cached connection is invalid

Actual Behavior

VS Code finds the stale data.json file and assumes the server is still running, then repeatedly fails to connect:

[20:20:08.629] Found existing data file
[20:20:08.629] Found local server running: {"remoteListeningOn":{"port":38843},...,"pid":12788,...,"socksPort":57615,...}
[20:20:08.632] Found running server - short-circuiting install
[20:20:08.633] Starting forwarding server. local port 52025 -> socksPort 57615 -> remotePort 38843
[20:20:08.639] Failed to set up socket for dynamic port forward to remote port 38843: connect ECONNREFUSED 127.0.0.1:57615
[20:20:08.631] Server delay-shutdown request failed: connect ENOENT /var/folders/.../vscode-ssh-askpass-....sock

The errors repeat indefinitely because:

  1. The local SOCKS port (57615) is not listening → ECONNREFUSED
  2. The IPC socket doesn't exist → ENOENT
  3. The PID (12788) no longer exists

Workaround

Manually delete the stale metadata directory:

rm -rf ~/Library/Application\ Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-*

Note: The built-in "Remote-SSH: Kill VS Code Server on Host" command does NOT work in this scenario because it also requires the IPC socket to send the kill signal.

Root Cause

The Remote-SSH extension's "short-circuiting" logic trusts the existence of data.json without validating that:

  • The referenced PID actually exists on the local system
  • The SOCKS port is actually listening
  • The IPC socket file exists

After a crash, none of these are true, but VS Code never performs health checks before attempting to reuse the connection.

Related Issues

This appears to be the same issue as #2189 (open since January 2020).

Suggested Fix

Before "short-circuiting" the installation, validate the cached connection:

  1. Check if the local PID exists (if stored in metadata)
  2. Verify the SOCKS port is listening: netstat or attempt a test connection
  3. Verify the IPC socket exists: fs.existsSync(ipcHandlePath)
  4. If any validation fails: Delete the stale data.json and proceed with a fresh connection

This would make Remote-SSH resilient to crashes and eliminate the need for manual cleanup.

Steps To Reproduce
  1. Open a remote-ssh connection
  2. SIGKILL all the vscode related PIDs at once to simulate a system crash
  3. Restart vscode
  4. Try to reconnect to the same remote host
Anything else?

I'd love to help fix this issue, unfortunately the vscode remote-ssh extension is not open source, which is a real shame. Please consider open sourcing the extension.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names stale data.json metadata, IPC sockets, SOCKS ports, and the short-circuiting connection path, but identifies no repository file or test. First confirm whether the Remote-SSH extension source is available here; the report says it is not open source, so there may be no entry point for a first-time contributor. Done would require crash recovery to establish a fresh connection without manual metadata deletion.

Written by the indexing model from the issue text.

Assessment

Tech stack
vscode
Domain
devtools, networking
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.