{"record":{"id":"caebc41f88738a2d","repo":"zed-industries/zed","slug":"cannot-fetch-host-loopback-and-ip-literal-hos","errorCode":null,"errorMessage":"cannot fetch {host:?}: loopback and IP-literal hosts can't be granted network access individually. They are only reachable once unsandboxed access has been granted (for example, via a terminal command that requests it).","messagePattern":"cannot fetch (.+?): loopback and IP-literal hosts can't be granted network access individually\\. They are only reachable once unsandboxed access has been granted \\(for example, via a terminal command that requests it\\)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/tools/fetch_tool.rs","lineNumber":205,"sourceCode":"        .port_or_known_default()\n        .unwrap_or(if parsed.scheme() == \"http\" { 80 } else { 443 });\n\n    http_proxy::PinnedHost::resolve(host, port).map(|_pinned| ())?;\n    Ok(())\n}\n\n/// Extracts the host from a fetch URL as a [`http_proxy::HostPattern`] so it can\n/// be matched against the shared network grants. Mirrors the scheme handling in\n/// [`normalize_url`] (defaulting to `https://` when none is given).\nfn host_pattern_for_url(url: &str) -> Result<http_proxy::HostPattern> {\n    let normalized = normalize_url(url);\n    let parsed =\n        url::Url::parse(&normalized).with_context(|| format!(\"could not parse URL {url:?}\"))?;\n    let host = parsed\n        .host_str()\n        .with_context(|| format!(\"URL {url:?} has no host to authorize network access for\"))?;\n    http_proxy::HostPattern::parse(host).map_err(|error| match error {\n        http_proxy::HostPatternError::IpLiteral(_) => anyhow::anyhow!(\n            \"cannot fetch {host:?}: loopback and IP-literal hosts can't be granted network \\\n             access individually. They are only reachable once unsandboxed access has been \\\n             granted (for example, via a terminal command that requests it).\"\n        ),\n        error => anyhow::anyhow!(\"cannot authorize network access to {host:?}: {error}\"),\n    })\n}\n\nimpl AgentTool for FetchTool {\n    type Input = FetchToolInput;\n    type Output = String;\n\n    const NAME: &'static str = \"fetch\";\n\n    fn kind() -> acp::ToolKind {\n        acp::ToolKind::Fetch\n    }\n","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/agent/src/tools/fetch_tool.rs#L187-L223","documentation":"host_pattern_for_url rejects fetch targets whose host is a loopback address or raw IP literal, because network grants cannot be expressed for individual IPs; such hosts are only reachable with unsandboxed network access.","triggerScenarios":"Thrown at crates/agent/src/tools/fetch_tool.rs:205 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Loopback and raw IP hosts cannot be granted per-host network access; run the fetch unsandboxed (e.g. from a terminal command that requests network access) instead","Use a resolvable domain name rather than an IP literal where possible","Adjust sandbox/network grant settings to allow the required access globally"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}