zed-industries/zed · error

invalid URL scheme: {scheme}

Error message

invalid URL scheme: {scheme}

What it means

To open the Cloud WebSocket on native targets, the /client/users/connect URL scheme must be upgraded https→wss or http→ws. This error fires when build_zed_cloud_url produced a URL with any other scheme, so no websocket scheme mapping exists.

Source

Thrown at crates/cloud_api_client/src/websocket/native.rs:71

                    }
                }
            }
        });

        (message_rx.into_stream().boxed(), task)
    }
}

impl CloudApiClient {
    pub fn connect(self: &std::sync::Arc<Self>, cx: &App) -> Result<Task<Result<Connection>>> {
        let mut connect_url = self
            .http_client
            .build_zed_cloud_url("/client/users/connect")?;
        connect_url
            .set_scheme(match connect_url.scheme() {
                "https" => "wss",
                "http" => "ws",
                scheme => Err(anyhow!("invalid URL scheme: {scheme}"))?,
            })
            .map_err(|_| anyhow!("failed to set URL scheme"))?;

        let credentials = self.credentials.read();
        let credentials = credentials.as_ref().context("no credentials provided")?;
        let authorization_header = format!("{} {}", credentials.user_id, credentials.access_token);

        Ok(gpui_tokio::Tokio::spawn_result(cx, async move {
            let websocket = WebSocket::connect(connect_url)
                .with_request(
                    request::Builder::new()
                        .header("Authorization", authorization_header)
                        .header(PROTOCOL_VERSION_HEADER_NAME, PROTOCOL_VERSION.to_string()),
                )
                .await?;

            Ok(Connection::new(websocket))
        }))

View on GitHub (pinned to bc538def45)

Solutions

  1. Set the cloud base URL to https:// (the code derives wss itself)
  2. Print/verify the resolved URL before connect and check its scheme
  3. Remove any stale custom-URL overrides and retry with defaults

Example fix

# before
export ZED_CLOUD_URL=wss://cloud.example.com

# after
export ZED_CLOUD_URL=https://cloud.example.com
Defensive patterns

Strategy: validation

Validate before calling

let connect_url = http_client.build_zed_cloud_url("/client/users/connect")?;
if !matches!(connect_url.scheme(), "http" | "https") {
    anyhow::bail!("cloud base URL must be http(s), got scheme {}", connect_url.scheme());
}

Type guard

fn is_http_cloud_url(url: &url::Url) -> bool {
    matches!(url.scheme(), "http" | "https") && url.host_str().is_some()
}

Prevention

When it happens

Trigger: A custom cloud base URL configured with a scheme other than http/https (e.g. wss://, file://), producing a connect URL whose scheme matches neither branch of the match.

Common situations: Self-hosted or enterprise deployments overriding the cloud base URL and mistakenly entering a websocket scheme; typo'd environment configuration.

Related errors


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