{"record":{"id":"a5f524cbce26fca5","repo":"rust-lang/rust","slug":"failed-to-lookup-address-information-detail","errorCode":null,"errorMessage":"failed to lookup address information: {detail}","messagePattern":"failed to lookup address information: (.+?)","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"library/std/src/sys/net/connection/socket/hermit.rs","lineNumber":27,"sourceCode":"use crate::net::{Shutdown, SocketAddr};\nuse crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, RawFd};\nuse crate::sys::fd::FileDesc;\nuse crate::sys::{AsInner, FromInner, IntoInner};\npub use crate::sys::{cvt, cvt_r};\nuse crate::time::{Duration, Instant};\nuse crate::{cmp, mem};\n\n#[expect(non_camel_case_types)]\npub type wrlen_t = usize;\n\npub fn cvt_gai(err: i32) -> io::Result<()> {\n    if err == 0 {\n        return Ok(());\n    }\n\n    let detail = \"\";\n\n    Err(io::Error::new(\n        io::ErrorKind::Uncategorized,\n        &format!(\"failed to lookup address information: {detail}\")[..],\n    ))\n}\n\npub fn init() {}\n\n#[derive(Debug)]\npub struct Socket(FileDesc);\n\nimpl Socket {\n    pub fn new(fam: i32, ty: i32) -> io::Result<Socket> {\n        let fd = cvt(unsafe { netc::socket(fam, ty, 0) })?;\n        Ok(Socket(unsafe { FileDesc::from_raw_fd(fd) }))\n    }\n\n    pub fn new_pair(_fam: i32, _ty: i32) -> io::Result<(Socket, Socket)> {\n        unimplemented!()","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/library/std/src/sys/net/connection/socket/hermit.rs#L9-L45","documentation":"Emitted by Rust std's HermitOS getaddrinfo wrapper cvt_gai when the underlying Hermit network stack returns a non-zero error code from name resolution. The detail string is hardcoded empty on Hermit (libc::gai_strerror is unavailable), so the message carries no OS-level explanation. ErrorKind is Uncategorized, which is why it surfaces as a generic io::Error.","triggerScenarios":"Any DNS lookup (to_socket_addrs, TcpStream::connect with a hostname, UdpSocket::bind) on the Hermit unikernel target when the resolver fails - e.g. unreachable DNS server, malformed hostname, unsupported address family, or network driver not initialized. cvt_gai returns the formatted error for every non-zero gai return.","commonSituations":"Running a networked Rust program under the HermitOS unikernel without a configured network gateway; DNS server unreachable inside the VM; hostname syntax unsupported by the unikernel resolver.","solutions":["Verify the Hermit network driver is loaded and a gateway/DNS server is configured for the VM.","Pass a literal IP address instead of a hostname to bypass the resolver entirely.","Check hostname validity and address-family support in the Hermit network stack before connecting.","Inspect the underlying Hermit network error via its logs, since std gives no detail string."],"exampleFix":"// before\nlet addrs = (\"api.example.com\", 443).to_socket_addrs()?;\n\n// after\nlet addr: SocketAddr = ([93,184,216,34], 443).into();\nlet s = TcpStream::connect(addr)?;","handlingStrategy":"validation","validationCode":"fn resolve_or_ip(host: &str, port: u16) -> io::Result<std::net::SocketAddr> {\n    if let Ok(ip) = host.parse::<std::net::IpAddr>() {\n        return Ok(std::net::SocketAddr::new(ip, port));\n    }\n    (host, port).to_socket_addrs()?.next().ok_or_else(||\n        io::Error::new(io::ErrorKind::Uncategorized, \"no addr\"))\n}","typeGuard":null,"tryCatchPattern":"match (host, port).to_socket_addrs() {\n    Ok(mut it) => Ok(it.next().unwrap()),\n    Err(e) if e.to_string().contains(\"failed to lookup address information\") => {\n        // log Hermit network state, then fallback to configured IP\n        Err(e)\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Prefer literal IP addresses on Hermit to avoid the resolver path.","Confirm the Hermit network driver and DNS gateway are configured before lookups.","Log the raw err code since std provides no detail string."],"tags":["rust","std","network","hermit","dns","unikernel","socket"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}