{"record":{"id":"8357fd1f3d7d95a5","repo":"shadowsocks/shadowsocks-rust","slug":"initialize-dns-resolver-with-system-config-failed","errorCode":null,"errorMessage":"initialize DNS resolver with system-config failed, error: {}","messagePattern":"initialize DNS resolver with system-config failed, error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/shadowsocks/src/dns_resolver/hickory_dns_resolver.rs","lineNumber":195,"sourceCode":"                    // Only ip_strategy should be changed. Why Ipv4AndIpv6? See comments above.\n                    opts.ip_strategy = LookupIpStrategy::Ipv4AndIpv6;\n\n                    // Enable EDNS0 for large records\n                    opts.edns0 = true;\n\n                    trace!(\"initializing DNS resolver with system-config opts {:?}\", opts);\n\n                    match builder.build() {\n                        Ok(resolver) => Ok(resolver),\n                        Err(err) => {\n                            error!(\"initialize DNS resolver with config failed, error: {}\", err);\n                            Err(io::Error::new(io::ErrorKind::Other, err))\n                        }\n                    }\n                }\n                Err(err) => {\n                    error!(\"initialize DNS resolver with system-config failed, error: {}\", err);\n                    Err(io::Error::new(io::ErrorKind::Other, err))\n                }\n            }\n        }\n    }\n}\n","sourceCodeStart":177,"sourceCodeEnd":201,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/crates/shadowsocks/src/dns_resolver/hickory_dns_resolver.rs#L177-L201","documentation":"shadowsocks failed to build a DNS resolver from the OS system configuration (e.g. /etc/resolv.conf) when using the hickory-dns (trust-dns) backend. The underlying cause is the wrapped hickory resolver bootstrap error; shadowsocks wraps it into io::ErrorKind::Other and aborts resolver creation, so any lookup using this resolver cannot proceed.","triggerScenarios":"Calling create_resolver (via hickory_dns_system_resolver, hickory_dns_notify_update_dns, or hickory_resolver) when the system DNS config is missing, unreadable, or malformed, or when hickory-dns fails to bootstrap its runtime/connection for the configured nameservers.","commonSituations":"Containers or minimal images without /etc/resolv.conf; malformed resolv.conf entries; hickory-dns version incompatibilities; sandboxed environments where reading system config is blocked; IPv6-only or broken nameserver entries.","solutions":["Check that /etc/resolv.conf exists and is well-formed (valid nameserver lines) in the runtime environment","Inspect the inner error text logged by error! to identify the hickory-dns root cause","Fall back to the built-in (non-hickory) DNS resolver, e.g. use_dns_resolver with the ordinary resolver instead of hickory-dns","Verify the hickory-dns feature/version matches what shadowsocks expects and update both crates together"],"exampleFix":"// before\nlet resolver = hickory_dns_system_resolver().await?;\n// after\nlet resolver = match hickory_dns_system_resolver().await {\n    Ok(r) => r,\n    Err(e) => {\n        log::warn!(\"hickory system resolver unavailable: {}\", e);\n        DnsResolver::dns().await // built-in fallback\n    }\n};","handlingStrategy":"fallback","validationCode":"if !std::path::Path::new(\"/etc/resolv.conf\").exists() {\n    eprintln!(\"system DNS config missing; use built-in resolver\");\n}","typeGuard":null,"tryCatchPattern":"let resolver = match hickory_dns_system_resolver().await {\n    Ok(r) => r,\n    Err(e) => { warn!(\"hickory resolver failed: {}\", e); DnsResolver::dns().await? }\n};","preventionTips":["Ensure /etc/resolv.conf exists and is valid in the deployment image","Pin compatible hickory-dns and shadowsocks versions","Configure an explicit fallback resolver instead of relying on system config"],"tags":["dns","resolver-init","network","rust"],"backgroundTag":"module-init-failed","analyzedSha":"8eb0f0a65b1d976ab6bed5787327ef86529b0435","analyzedAt":"2026-09-09T12:20:43.168Z","contentChangedAt":"2026-09-09T12:20:43.168Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}