{"record":{"id":"0cc37bbcdd86e180","repo":"zed-industries/zed","slug":"failed-to-connect-to-cloud-websocket-error","errorCode":null,"errorMessage":"failed to connect to Cloud WebSocket: {error}","messagePattern":"failed to connect to Cloud WebSocket: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cloud_api_client/src/websocket/web.rs","lineNumber":72,"sourceCode":"        let executor = cx.background_executor().clone();\n        Ok(cx.spawn(async move |_cx| {\n            let mut connect_url = client\n                .http_client\n                .build_zed_cloud_url(\"/client/users/connect\")?;\n            connect_url\n                .set_scheme(match connect_url.scheme() {\n                    \"https\" => \"wss\",\n                    \"http\" => \"ws\",\n                    scheme => return Err(anyhow!(\"invalid URL scheme: {scheme}\")),\n                })\n                .map_err(|_| anyhow!(\"failed to set URL scheme\"))?;\n\n\n            let connect = WebSocket::connect(connect_url).fuse();\n            let timeout = executor.timer(CONNECT_TIMEOUT).fuse();\n            futures::pin_mut!(connect, timeout);\n            let websocket = futures::select_biased! {\n                result = connect => result.map_err(|error| anyhow!(\"failed to connect to Cloud WebSocket: {error}\"))?,\n                _ = timeout => return Err(anyhow!(\"timed out connecting to Cloud WebSocket\")),\n            };\n\n            Ok(Connection::new(websocket))\n        }))\n    }\n}\n","sourceCodeStart":54,"sourceCodeEnd":80,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/cloud_api_client/src/websocket/web.rs#L54-L80","documentation":"Web (wasm) build: the WebSocket::connect future raced against a CONNECT_TIMEOUT timer and the connect side finished with an error, which is wrapped with this message. The TCP/TLS/websocket handshake to the Cloud endpoint failed outright.","triggerScenarios":"WebSocket::connect errors within the timeout: DNS failure, blocked wss port, TLS certificate rejection, proxy refusing websocket upgrades, or server unreachable.","commonSituations":"Corporate firewalls blocking outbound wss; browser security policies; cloud API endpoint temporarily down; self-signed certificates in test environments.","solutions":["Verify wss connectivity to the cloud host (browser devtools or `curl --include --no-buffer https://host/client/users/connect -H 'Connection: Upgrade' -H 'Upgrade: websocket'`)","Allow websocket traffic through firewalls/proxies (wss on 443)","Check https://status.zed.dev and retry after the endpoint recovers"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"let websocket = futures::select_biased! {\n    result = connect => match result {\n        Ok(ws) => ws,\n        Err(error) => {\n            // handshake failed: backoff, then one bounded retry\n            executor.timer(Duration::from_secs(2)).await;\n            WebSocket::connect(connect_url.clone()).await?\n        }\n    },\n    _ = timeout => return Err(anyhow!(\"timed out connecting to Cloud WebSocket\")),\n};","preventionTips":["Allow wss on 443 through corporate firewalls and proxies","Retry with bounded backoff on connect failures; cap attempts","Surface connect failures distinctly from mid-stream frame errors"],"tags":["websocket","network","timeout","wasm"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}