nodejs/node · error

Failed to create query for %s: %s

Error message

Failed to create query for %s: %s

What it means

Printed by adig's main() at adig.c:1557 when enqueue_query() returns a status other than ARES_SUCCESS. enqueue_query creates the DNS query for global_config.name using the configured query type and class. The message includes the query name and the ares_strerror() detail. The tool sets rv=1 and jumps to cleanup.

Source

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

    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));
    printf(" %s", global_config.name);
    printf("\n");
  }

  /* Enqueue a query for each separate name */
  status = enqueue_query(channel);
  if (status != ARES_SUCCESS) {
    fprintf(stderr, "Failed to create query for %s: %s\n", global_config.name,
            ares_strerror((int)status));
    rv = 1;
    goto done;
  }

  /* Process events */
  rv = event_loop(channel);

done:
  free_config();
  ares_destroy(channel);
  ares_library_cleanup();

#ifdef USE_WINSOCK
  WSACleanup();
#endif
  return rv;
}

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Check the ares_strerror() output for the specific failure (e.g., ARES_EBADNAME for invalid domain name).
  2. Validate the domain name length (max 253 chars) and label length (max 63 chars per label) before querying.
  3. If using internationalized domain names, ensure IDN processing is enabled or convert to punycode first.
  4. Verify the query type is supported by the c-ares version (use standard types: A, AAAA, CNAME, MX, TXT, NS, SOA, SRV).

Example fix

// before: invalid domain name
adig 'exceedingly-long-label-'$(printf 'a%.0s' {1..70})'.example.com'
// -> 'Failed to create query for ...: ...'

// after: validate name length before querying
name='my.example.com'
[ ${#name} -le 253 ] && adig "$name" || echo 'name too long'
Defensive patterns

Strategy: validation

Validate before calling

// Validate domain name before querying
validate_domain() {
    local name="$1"
    [ ${#name} -le 253 ] || { echo "name too long" >&2; return 1; }
    # check each label is <= 63 chars and contains valid chars
    IFS='.' read -ra labels <<< "$name"
    for label in "${labels[@]}"; do
        [ ${#label} -le 63 ] || { echo "label too long" >&2; return 1; }
    done
}
validate_domain "$DOMAIN" && adig "$DOMAIN"

Try / catch

status = enqueue_query(channel);
if (status != ARES_SUCCESS) {
    fprintf(stderr, "query creation failed: %s\n", ares_strerror((int)status));
    // skip this name, continue with others if batch processing
}

Prevention

When it happens

Trigger: Calling enqueue_query(channel) at line 1555 after the channel is successfully initialized. Fails when c-ares cannot construct the DNS query packet — e.g., the domain name exceeds 253 characters, contains invalid label characters, has labels exceeding 63 bytes, or the query type is unsupported by the c-ares version in use.

Common situations: A user queries an excessively long or malformed domain name. The query name contains characters that are not valid in DNS labels (underscores in hostnames, spaces, non-ASCII without IDN processing). The query type was set to a value c-ares does not support.

Related errors


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