zed-industries/zed · error
cannot fetch : loopback and IP-literal hosts can't be…
Error message
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). What it means
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.
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
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/agent/src/tools/fetch_tool.rs:205 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/caebc41f88738a2d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/agent/src/tools/fetch_tool.rs:205
.port_or_known_default()
.unwrap_or(if parsed.scheme() == "http" { 80 } else { 443 });
http_proxy::PinnedHost::resolve(host, port).map(|_pinned| ())?;
Ok(())
}
/// Extracts the host from a fetch URL as a [`http_proxy::HostPattern`] so it can
/// be matched against the shared network grants. Mirrors the scheme handling in
/// [`normalize_url`] (defaulting to `https://` when none is given).
fn host_pattern_for_url(url: &str) -> Result<http_proxy::HostPattern> {
let normalized = normalize_url(url);
let parsed =
url::Url::parse(&normalized).with_context(|| format!("could not parse URL {url:?}"))?;
let host = parsed
.host_str()
.with_context(|| format!("URL {url:?} has no host to authorize network access for"))?;
http_proxy::HostPattern::parse(host).map_err(|error| match error {
http_proxy::HostPatternError::IpLiteral(_) => anyhow::anyhow!(
"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)."
),
error => anyhow::anyhow!("cannot authorize network access to {host:?}: {error}"),
})
}
impl AgentTool for FetchTool {
type Input = FetchToolInput;
type Output = String;
const NAME: &'static str = "fetch";
fn kind() -> acp::ToolKind {
acp::ToolKind::Fetch
}
View on GitHub (pinned to f4178619ac)