zed-industries/zed · error

invalid rpc url: {}

Error message

invalid rpc url: {}

What it means

Before connecting, the client validates that the resolved RPC URL scheme is exactly http or https. Any other scheme (file, wss, ssh, missing scheme from a malformed string) is rejected immediately with the full URL printed.

Source

Thrown at crates/client/src/client.rs:1354

        let user_agent = http.user_agent().cloned();
        let credentials = credentials.clone();
        let rpc_url = self.rpc_url(http, release_channel);
        let system_id = self.telemetry.system_id();
        let metrics_id = self.telemetry.metrics_id();
        cx.spawn(async move |cx| {
            use HttpOrHttps::*;

            #[derive(Debug)]
            enum HttpOrHttps {
                Http,
                Https,
            }

            let mut rpc_url = rpc_url.await?;
            let url_scheme = match rpc_url.scheme() {
                "https" => Https,
                "http" => Http,
                _ => Err(anyhow!("invalid rpc url: {}", rpc_url))?,
            };

            let stream = gpui_tokio::Tokio::spawn_result(cx, {
                let rpc_url = rpc_url.clone();
                async move {
                    let rpc_host = rpc_url
                        .host_str()
                        .zip(rpc_url.port_or_known_default())
                        .context("missing host in rpc url")?;
                    Ok(match proxy {
                        Some(proxy) if !excluded_from_proxy(rpc_host.0) => {
                            connect_proxy_stream(&proxy, rpc_host).await?
                        }
                        _ => Box::new(TcpStream::connect(rpc_host).await?),
                    })
                }
            })
            .await?;

View on GitHub (pinned to bc538def45)

Solutions

  1. Set the URL with a proper scheme: `https://your-server.example.com` (or `http://` for local dev)
  2. Re-check the full URL string for typos; the error message prints exactly what was parsed
  3. If the bad URL came from the /rpc Location header, fix the server's redirect target

Example fix

# before
export ZED_SERVER_URL=wss://zed.example.com

# after
export ZED_SERVER_URL=https://zed.example.com
Defensive patterns

Strategy: validation

Validate before calling

fn valid_rpc_url(url: &str) -> bool {
    matches!(url::Url::parse(url), Ok(parsed) if matches!(parsed.scheme(), "http" | "https"))
}

assert!(valid_rpc_url(&server_url), "server URL must be http(s): {server_url}");

Type guard

fn as_http_url(s: &str) -> Option<url::Url> {
    url::Url::parse(s).ok().filter(|u| matches!(u.scheme(), "http" | "https"))
}

Prevention

When it happens

Trigger: The final rpc_url (from /rpc discovery or direct configuration) has a scheme other than http/https: typos like `htp://`, base URLs entered as `wss://host`, or a URL missing the `//` separator.

Common situations: Users pasting a websocket URL where an https URL belongs; environment variables (ZED_SERVER_URL) with stray characters; config files edited by hand.

Related errors


AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16). Data as JSON: /api/errors/717b9e9632c07d37. Report an issue: GitHub.