{"record":{"id":"b1fdee5a200d21c1","repo":"rust-lang/rust","slug":"failed-to-lookup-address-information-msg","errorCode":null,"errorMessage":"failed to lookup address information: {msg}","messagePattern":"failed to lookup address information: (.+?)","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"library/std/src/sys/net/connection/socket/solid.rs","lineNumber":59,"sourceCode":"\npub fn cvt<T: IsMinusOne>(t: T) -> io::Result<T> {\n    if t.is_minus_one() { Err(last_error()) } else { Ok(t) }\n}\n\n/// A variant of `cvt` for `getaddrinfo` which return 0 for a success.\npub fn cvt_gai(err: c_int) -> io::Result<()> {\n    if err == 0 {\n        Ok(())\n    } else {\n        let msg: &dyn crate::fmt::Display = match err {\n            netc::EAI_NONAME => &\"name or service not known\",\n            netc::EAI_SERVICE => &\"service not supported\",\n            netc::EAI_FAIL => &\"non-recoverable failure in name resolution\",\n            netc::EAI_MEMORY => &\"memory allocation failure\",\n            netc::EAI_FAMILY => &\"family not supported\",\n            _ => &err,\n        };\n        Err(io::Error::new(\n            io::ErrorKind::Uncategorized,\n            &format!(\"failed to lookup address information: {msg}\")[..],\n        ))\n    }\n}\n\n/// Just to provide the same interface as sys/pal/unix/net.rs\npub fn cvt_r<T, F>(mut f: F) -> io::Result<T>\nwhere\n    T: IsMinusOne,\n    F: FnMut() -> T,\n{\n    cvt(f())\n}\n\n/// Returns the last error from the network subsystem.\nfn last_error() -> io::Error {\n    io::Error::from_raw_os_error(unsafe { netc::SOLID_NET_GetLastError() })","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/library/std/src/sys/net/connection/socket/solid.rs#L41-L77","documentation":"Thrown by Rust std's SOLID-OS getaddrinfo wrapper cvt_gai for any non-zero gai error code. It maps well-known codes (EAI_NONAME, EAI_SERVICE, EAI_FAIL, EAI_MEMORY, EAI_FAMILY) to human-readable sub-messages; any unrecognized code falls back to printing the numeric error. ErrorKind is Uncategorized.","triggerScenarios":"DNS or service-name resolution failing on the SOLID real-time OS: unknown hostname (EAI_NONAME), unsupported service (EAI_SERVICE), non-recoverable resolver failure (EAI_FAIL), memory exhaustion (EAI_MEMORY), or unsupported address family (EAI_FAMILY). Reached via to_socket_addrs and the connect/bind family.","commonSituations":"Embedded/RTOS deployment on SOLID with no DNS server reachable; specifying a service name not in /etc/services equivalent; requesting IPv6 on an IPv4-only SOLID stack; typo in hostname.","solutions":["Match the embedded sub-message: 'name or service not known' -> fix hostname; 'family not supported' -> use IPv4; 'service not supported' -> use a numeric port.","Confirm the SOLID network subsystem and DNS resolver are initialized before the lookup.","Prefer literal IP and numeric port to avoid the resolver path entirely.","Log the numeric err value when the message falls through to the default arm."],"exampleFix":"// before\nlet s = TcpStream::connect(\"svc.example.com:https\")?;\n\n// after\nlet addr: SocketAddr = ([10,0,0,5], 443).into();\nlet s = TcpStream::connect(addr)?;","handlingStrategy":"validation","validationCode":"fn safe_lookup(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()\n        .ok_or_else(|| 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) => {\n        let msg = e.to_string();\n        if msg.contains(\"family not supported\") { /* switch family */ }\n        else if msg.contains(\"name or service not known\") { /* fix host */ }\n        Err(e)\n    }\n}","preventionTips":["Use literal IPs and numeric ports to bypass the resolver on SOLID.","Map the embedded sub-message to a recovery action in a shared helper.","Log the numeric err for the default-arm case."],"tags":["rust","std","network","solid","rtos","dns","socket"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}