zed-industries/zed · error
connecting to host timed out
Error message
connecting to host timed out
What it means
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.
Source
Thrown at crates/remote/src/transport/ssh.rs:690
// for establish the connection and keep it open, allowing other ssh
// commands to reuse it via a control socket.
let socket_path = temp_dir.path().join("ssh.sock");
let mut master_process = MasterProcess::new(
askpass.script_path().as_ref(),
connection_options.additional_args(),
&socket_path,
&destination,
)?;
let result = select_biased! {
result = askpass.run(Some(SSH_CONNECTION_PROMPT_TIMEOUT)).fuse() => {
match result {
AskPassResult::CancelledByUser => {
master_process.as_mut().kill().ok();
anyhow::bail!("SSH connection canceled")
}
AskPassResult::Timedout => {
anyhow::bail!("connecting to host timed out")
}
}
}
_ = master_process.wait_connected().fuse() => {
anyhow::Ok(())
}
};
if let Err(e) = result {
return Err(e.context("Failed to connect to host"));
}
if master_process.as_mut().try_status()?.is_some() {
let mut output = Vec::new();
let mut stderr = master_process.as_mut().stderr.take().unwrap();
stderr.read_to_end(&mut output).await?;
let error_message = format!(View on GitHub (pinned to f4178619ac)
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
Defensive patterns
Strategy: retry
Validate before calling
// Preflight reachability so ssh does not hang into the prompt timeout: // ssh -o BatchMode=yes -o ConnectTimeout=5 -T <user>@<host> true
Try / catch
match connect(&opts, cx).await {
Err(e) if e.to_string().contains("connecting to host timed out") && retries < MAX => {
retries += 1;
backoff(retries).await;
continue;
}
other => break other,
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Timed out when connecting to debugger
- ssh process exited before connection established
- SSH connection canceled
- failed to connect: {}
- build ids may only contain lowercase letters, numbers, '.',
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/7532e563b3b5faf3.
Report an issue: GitHub.