{"record":{"id":"c3fa8c426720d015","repo":"nodejs/node","slug":"s-s","errorCode":null,"errorMessage":"%s: %s\n","messagePattern":"%s: %s\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/cares/src/tools/ahost.c","lineNumber":217,"sourceCode":"  ares_destroy(channel);\n\n  ares_library_cleanup();\n\n#ifdef USE_WINSOCK\n  WSACleanup();\n#endif\n\n  return 0;\n}\n\nstatic void callback(void *arg, int status, int timeouts, struct hostent *host)\n{\n  char **p;\n\n  (void)timeouts;\n\n  if (status != ARES_SUCCESS) {\n    fprintf(stderr, \"%s: %s\\n\", (char *)arg, ares_strerror(status));\n    return;\n  }\n\n  for (p = host->h_addr_list; *p; p++) {\n    char addr_buf[46] = \"??\";\n\n    ares_inet_ntop(host->h_addrtype, *p, addr_buf, sizeof(addr_buf));\n    printf(\"%-32s\\t%s\", host->h_name, addr_buf);\n    puts(\"\");\n  }\n}\n\nstatic void ai_callback(void *arg, int status, int timeouts,\n                        struct ares_addrinfo *result)\n{\n  struct ares_addrinfo_node *node = NULL;\n  (void)timeouts;\n","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/cares/src/tools/ahost.c#L199-L235","documentation":"Printed by ahost's callback() at ahost.c:217 when the DNS lookup initiated by ares_gethostbyname or ares_gethostbyaddr completes with a non-success status. The callback receives (arg, status, timeouts, host) where arg is the original hostname/IP string. The message formats as 'hostname: ares-error-string'. The callback returns without printing addresses since none are available.","triggerScenarios":"The callback registered with ares_gethostbyname/ares_gethostbyaddr is invoked by c-ares with status != ARES_SUCCESS. Triggered when the DNS server returns NXDOMAIN (ARES_ENOTFOUND), a SERVFAIL (ARES_ESERVFAIL), a timeout (ARES_ETIMEOUT after all retries), or when the name cannot be resolved for the requested family (e.g., querying AAAA for a name with only A records returns ARES_ENODATA).","commonSituations":"Looking up a nonexistent domain (NXDOMAIN). The DNS server is unreachable (timeout). Querying AAAA records for an IPv4-only domain. The domain exists but has no records of the requested type. Network connectivity issues prevent reaching the configured DNS resolver.","solutions":["Check the ares_strerror() portion of the message: ENOTFOUND means the name does not exist, ETIMEOUT means the resolver is unreachable.","Verify the domain name is spelled correctly and exists in DNS (cross-check with 'dig' or 'nslookup').","For AAAA failures, confirm the domain actually has IPv6 records (try -t a instead of -t aaaa).","If timeouts persist, verify network connectivity to the DNS server and try an alternate resolver (-s 8.8.8.8)."],"exampleFix":"// before: querying AAAA for IPv4-only domain\nahost -t aaaa ipv4-only.example.com\n// -> 'ipv4-only.example.com: ...'\n\n// after: query the correct record type\nahost -t a ipv4-only.example.com","handlingStrategy":"fallback","validationCode":"// Pre-check domain existence is not practical for DNS.\n// Instead, validate name syntax before querying:\nvalidate_domain() {\n    local name=\"$1\"\n    [ ${#name} -le 253 ] || return 1\n    return 0\n}\nvalidate_domain \"$DOMAIN\" || { echo \"invalid name\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":"// In the callback, handle non-success gracefully\nstatic void callback(void *arg, int status, int timeouts, struct hostent *host) {\n    if (status != ARES_SUCCESS) {\n        fprintf(stderr, \"%s: %s\\n\", (char *)arg, ares_strerror(status));\n        // fall back to alternate resolver or report gracefully\n        return;\n    }\n    // process host->h_addr_list\n}","preventionTips":["Verify domain names exist before scripted lookups (e.g., with a preliminary check).","For AAAA queries, confirm the domain has IPv6 records or fall back to A records.","Configure alternate DNS servers to improve resilience against resolver failures.","Handle ARES_ENOTFOUND and ARES_ETIMEOUT distinctly in callback logic."],"tags":["c-ares","ahost","dns-lookup","callback","nxdomain","network"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}