{"record":{"id":"7532e563b3b5faf3","repo":"zed-industries/zed","slug":"connecting-to-host-timed-out","errorCode":null,"errorMessage":"connecting to host timed out","messagePattern":"connecting to host timed out","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/remote/src/transport/ssh.rs","lineNumber":690,"sourceCode":"            // for establish the connection and keep it open, allowing other ssh\n            // commands to reuse it via a control socket.\n            let socket_path = temp_dir.path().join(\"ssh.sock\");\n            let mut master_process = MasterProcess::new(\n                askpass.script_path().as_ref(),\n                connection_options.additional_args(),\n                &socket_path,\n                &destination,\n            )?;\n\n            let result = select_biased! {\n                result = askpass.run(Some(SSH_CONNECTION_PROMPT_TIMEOUT)).fuse() => {\n                    match result {\n                        AskPassResult::CancelledByUser => {\n                            master_process.as_mut().kill().ok();\n                            anyhow::bail!(\"SSH connection canceled\")\n                        }\n                        AskPassResult::Timedout => {\n                            anyhow::bail!(\"connecting to host timed out\")\n                        }\n                    }\n                }\n                _ = master_process.wait_connected().fuse() => {\n                    anyhow::Ok(())\n                }\n            };\n\n            if let Err(e) = result {\n                return Err(e.context(\"Failed to connect to host\"));\n            }\n\n            if master_process.as_mut().try_status()?.is_some() {\n                let mut output = Vec::new();\n                let mut stderr = master_process.as_mut().stderr.take().unwrap();\n                stderr.read_to_end(&mut output).await?;\n\n                let error_message = format!(","sourceCodeStart":672,"sourceCodeEnd":708,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/remote/src/transport/ssh.rs#L672-L708","documentation":"The connect step races the askpass prompt against the master connection with SSH_CONNECTION_PROMPT_TIMEOUT; AskPassResult::Timedout means that timeout elapsed — the user neither completed nor cancelled the prompt and the ssh master had not finished connecting — so the attempt aborts.","triggerScenarios":"select_biased! resolves the askpass branch with Timedout: no user response to the password/passphrase prompt within the prompt timeout while the master connection is still pending (often because the host is slow or unreachable and hangs).","commonSituations":"Unattended or backgrounded machines where the prompt sits unanswered; black-holed networks where ssh hangs on connect; MFA/2FA flows that take longer than the allowed prompt window; VPN required but not up.","solutions":["Retry and answer the prompt promptly","Switch to key-based auth (agent-loaded or empty-passphrase key) to eliminate the prompt entirely","Fix reachability first: correct port, VPN up, bastion reachable, so ssh does not hang into the timeout","For recurring MFA logins, enable ControlMaster/ControlPersist multiplexing via additional ssh args so the prompt is rare"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Preflight reachability so ssh does not hang into the prompt timeout:\n// ssh -o BatchMode=yes -o ConnectTimeout=5 -T <user>@<host> true","typeGuard":null,"tryCatchPattern":"match connect(&opts, cx).await {\n    Err(e) if e.to_string().contains(\"connecting to host timed out\") && retries < MAX => {\n        retries += 1;\n        backoff(retries).await;\n        continue;\n    }\n    other => break other,\n}","preventionTips":["Prefer key auth so the prompt timeout cannot trigger","Ensure VPN/network to the host is up before connecting","For MFA hosts, use ControlMaster to amortize one interactive login"],"tags":["ssh","timeout","askpass","connection"],"backgroundTag":"ssh-connection-timeout","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}