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

  1. Retry and answer the prompt promptly
  2. Switch to key-based auth (agent-loaded or empty-passphrase key) to eliminate the prompt entirely
  3. Fix reachability first: correct port, VPN up, bastion reachable, so ssh does not hang into the timeout
  4. 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

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

Related errors


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/7532e563b3b5faf3. Report an issue: GitHub.