tonhowtf/omniget · error
Failed to build HTTP client
Error message
Failed to build HTTP client: {} What it means
Thrown in DirectFileDownloader::download when reqwest::ClientBuilder::build() fails after applying proxy/cookie/timeout settings, mapped with anyhow! including the underlying reqwest error. It indicates the HTTP client could not be constructed at all — typically a TLS backend or proxy configuration problem, not a network failure of the request itself.
Solutions
- Read the wrapped reqwest error in the message — it names the failing builder setting.
- Check proxy env vars (HTTP_PROXY/HTTPS_PROXY/ALL_PROXY) and any global proxy config for malformed URLs; unset them to test.
- Ensure the reqwest TLS feature is enabled and CA certificates are present in the environment.
- Retry without the cookie jar / proxy overrides to isolate which builder option breaks.
Example fix
// before
let client = builder.build().map_err(|e| anyhow!("Failed to build HTTP client: {}", e))?;
// after: fall back to a default client when custom builder options are the problem
let client = builder.build().unwrap_or_else(|e| {
tracing::warn!("client build failed ({}), using default", e);
reqwest::Client::new()
}); Defensive patterns
Strategy: try-catch
Validate before calling
// check proxy env vars are well-formed before building
for v in ["HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY"] {
if let Ok(p) = std::env::var(v) {
url::Url::parse(&p).map_err(|_| anyhow!("{} is not a valid proxy URL: {}", v, p))?;
}
} Try / catch
match downloader.download(&info, &opts, tx).await {
Err(e) if e.to_string().contains("Failed to build HTTP client") => {
eprintln!("check proxy settings / TLS config: {}", e);
// retry with proxies disabled:
std::env::remove_var("HTTPS_PROXY");
retry_download().await
}
other => other,
} Prevention
- Keep proxy env vars as valid http(s):// URLs
- Enable a reqwest TLS feature and ensure system CA certificates exist (common in slim Docker images)
- Isolate builder options (proxy, cookie jar) so a failure can be attributed to one setting
- Pin reqwest versions to avoid TLS feature regressions on upgrade
When it happens
Trigger: Builder configured with an invalid or unreachable proxy (apply_global_proxy output), malformed cookie jar, or a reqwest build failure such as missing/unusable TLS backend (e.g. native-tls vs rustls mismatch) or invalid system proxy env vars.
Common situations: Users set HTTP_PROXY/HTTPS_PROXY env vars with invalid URLs; environments without CA certificates; builds with a TLS feature mismatch; corrupted cookie store configuration.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- api client init failed
- Failed to build HTTP client
- Proxy must include a scheme, e.g. http://127.0.0.1:7897
- Unsupported proxy scheme
- Proxy must include host and port, e.g. http://127.0.0.1:7897
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/c9fe08dc27584b9a.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/platforms/direct_file.rs:248
.connect_timeout(std::time::Duration::from_secs(30));
if let Some(ua) = opts.user_agent.as_deref() {
builder = builder.user_agent(ua);
}
let jar =
crate::core::cookie_parser::load_extension_cookies_for_url(file_url).or_else(|| {
opts.referer
.as_deref()
.and_then(crate::core::cookie_parser::load_extension_cookies_for_url)
});
if let Some(jar) = jar {
builder = builder.cookie_provider(jar);
}
let client = builder
.build()
.map_err(|e| anyhow!("Failed to build HTTP client: {}", e))?;
let mut headers = reqwest::header::HeaderMap::new();
if let Some(ref r) = opts.referer {
if let Ok(val) = reqwest::header::HeaderValue::from_str(r) {
headers.insert(reqwest::header::REFERER, val);
}
}
if let Some(ref hdrs) = opts.extra_headers {
for (name, value) in hdrs {
if let (Ok(hname), Ok(hval)) = (
reqwest::header::HeaderName::from_bytes(name.as_bytes()),
reqwest::header::HeaderValue::from_str(value),
) {
headers.insert(hname, hval);
}
}
}
http_client::inject_ua_header(&mut headers, opts.user_agent.as_deref());View on GitHub (pinned to 8600b91f42)