nodejs/node · error
missing servers
Error message
missing servers
What it means
Printed by ahost's main() at ahost.c:120 when the -s flag is passed but state.optarg is NULL — meaning no argument was supplied for the -s option. The message 'missing servers' is printed to stderr, followed by a call to usage(). The optarg being NULL typically indicates a malformed command line where -s is the last token with no following value.
Source
Thrown at deps/cares/src/tools/ahost.c:120
options.ndomains++;
options.domains = (char **)realloc(
options.domains, (size_t)options.ndomains * sizeof(char *));
options.domains[options.ndomains - 1] = strdup(state.optarg);
break;
case 't':
if (ares_strcaseeq(state.optarg, "a")) {
addr_family = AF_INET;
} else if (ares_strcaseeq(state.optarg, "aaaa")) {
addr_family = AF_INET6;
} else if (ares_strcaseeq(state.optarg, "u")) {
addr_family = AF_UNSPEC;
} else {
usage();
}
break;
case 's':
if (state.optarg == NULL) {
fprintf(stderr, "%s", "missing servers");
usage();
break;
}
if (servers) {
free(servers);
}
servers = strdup(state.optarg);
break;
case 'h':
case '?':
print_help_info_ahost();
break;
default:
usage();
break;
}
}
View on GitHub (pinned to 1b2de5e052)
Solutions
- Provide a valid server IP after -s: 'ahost -s 8.8.8.8 example.com'.
- If building the command in a script, check that the server variable is non-empty before including -s.
- Quote the argument properly: 'ahost -s "$SERVER_IP" example.com'.
- Review the full command line for option ordering issues — put -s and its value before positional arguments.
Example fix
// before: missing -s argument ahost -s example.com // -> 'missing servers' + usage // after: provide server IP ahost -s 8.8.8.8 example.com
Defensive patterns
Strategy: validation
Validate before calling
// Validate -s argument presence before invoking ahost
if [ -z "$SERVER_IP" ]; then
echo "error: server IP is required for -s" >&2
exit 1
fi
ahost -s "$SERVER_IP" "$DOMAIN" Prevention
- Always provide a value immediately after -s in the command line.
- In scripts, check that the server variable is non-empty before including -s.
- Place -s and its argument before positional (hostname) arguments.
When it happens
Trigger: Invoking ahost with '-s' as the last argument or followed by another flag (e.g., 'ahost -s -t a example.com' where -t is consumed as the -s argument by some getopt implementations, or 'ahost -s' with nothing after). The ares_getopt parser sets state.optarg to NULL when no value follows the option.
Common situations: A user forgets to provide the server list after -s. A shell script constructs the command dynamically and the server variable is empty, producing a command where no argument is bound to -s. Option ordering causes another flag to be interpreted as the -s argument.
Related errors
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/cdf7be4bb8905cbb.
Report an issue: GitHub.