nodejs/node · error

ares_init_options: %s

Error message

ares_init_options: %s

What it means

Printed by adig's main() at adig.c:1531 when ares_init_options() fails to create a DNS resolver channel. The function receives &channel, &global_config.options, and global_config.optmask — the configured options from command-line and rcfile parsing. The ares_strerror() detail identifies the specific failure. The tool sets rv=1 and jumps to cleanup, destroying any partially-created channel.

Source

Thrown at deps/cares/src/tools/adig.c:1531

  if (global_config.is_help) {
    print_help();
    goto done;
  }

  if (global_config.name == NULL) {
    printf("missing query name\n");
    print_help();
    rv = 1;
    goto done;
  }

  config_opts();

  status = (ares_status_t)ares_init_options(&channel, &global_config.options,
                                            global_config.optmask);
  if (status != ARES_SUCCESS) {
    fprintf(stderr, "ares_init_options: %s\n", ares_strerror((int)status));
    rv = 1;
    goto done;
  }

  if (global_config.servers) {
    status =
      (ares_status_t)ares_set_servers_ports_csv(channel, global_config.servers);
    if (status != ARES_SUCCESS) {
      fprintf(stderr, "ares_set_servers_ports_csv: %s: %s\n",
              ares_strerror((int)status), global_config.servers);
      rv = 1;
      goto done;
    }
  }

  /* Debug */
  if (global_config.opts.display_command) {
    printf("\n; <<>> c-ares DiG %s <<>>", ares_version(NULL));

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Check the ares_strerror() output for the specific failure code.
  2. Simplify the options: run adig with minimal flags (no -s, no custom timeouts) to isolate which option causes the failure.
  3. If using an rcfile, validate its contents or bypass it with --no-rcfile.
  4. Ensure optmask bits match fields actually set in the ares_options struct — mismatched bits cause init failures.

Example fix

// before: malformed options cause init failure
adig --timeout=-1 example.com
// -> 'ares_init_options: ...'

// after: use valid option values
adig --timeout=5 example.com
Defensive patterns

Strategy: validation

Validate before calling

// Before calling ares_init_options, validate option fields
if (options.timeout_ms == 0 && (optmask & ARES_OPT_TIMEOUT)) {
    fprintf(stderr, "invalid timeout\n");
    return -1;
}
// Ensure optmask bits correspond to initialized fields in options struct

Try / catch

status = (ares_status_t)ares_init_options(&channel, &options, optmask);
if (status != ARES_SUCCESS) {
    fprintf(stderr, "ares_init_options: %s\n", ares_strerror((int)status));
    // simplify options and retry, or fall back to ares_init()
    status = (ares_status_t)ares_init(&channel);
}

Prevention

When it happens

Trigger: Calling ares_init_options() at line 1529 after config_opts() has populated global_config.options and optmask. Fails when the options are internally inconsistent — e.g., an invalid socket send buffer size, a malformed domain list, an invalid timeout value, or the system lacks resources to create the internal sockets and channels.

Common situations: An adig configuration file (~/.adigrc or similar) contains malformed values. Command-line options override defaults with out-of-range values. The system is out of memory or file descriptors. A bitmask in optmask references options that were not properly initialized in the options struct.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/9a7928fce26ebc26. Report an issue: GitHub.