How to fix Error: NOTFOUND (no answers section) in Node.js

Node.jsINTERMEDIATEHIGHUpdated Dec 9, 2025· 133 views

The DNS NOTFOUND error occurs when a DNS server responds to a query but contains no answer records for the requested domain. This indicates the domain doesn't exist, is improperly configured, or the DNS server lacks the record information. This is different from timeouts or unreachable servers.

Quick fix

Fixes NOTFOUND

# Check if domain is accessible
curl -I https://example.com

# Or try to ping it
ping example.com

# Check domain registration
whois example.com
  1. Verify the domain exists and is accessible
  2. Test with dig to see the actual DNS response
  3. Check DNS propagation status
  4. Verify the domain is configured at your registrar
node.js — error
# Check if domain is accessible
curl -I https://example.com
# Or try to ping it
ping example.com
# Check domain registration
whois example.com
Error: NOTFOUND (no answers section)

What this error means

The NOTFOUND error in Node.js DNS operations indicates that a DNS query was successfully sent to and received by the DNS server, but the response contained no answer section. In other words, the DNS server performed the lookup and definitively answered: "I don't have a record for that domain." This differs from ENOTFOUND errors which occur when the DNS server doesn't respond at all. With NOTFOUND, the DNS infrastructure is working—the server is reachable and responding—but it cannot provide the requested record. The "no answers section" phrase means the DNS response packet structure is valid but the answer section (the part containing the requested A, AAAA, MX, or other records) is empty. This happens when: - The domain genuinely doesn't exist - The domain exists but has no records of the type you requested - DNS propagation is incomplete or misconfigured - The DNS server is authoritative but lacks the record information

Typical symptoms

  • Network requests fail with 'NOTFOUND' error message
  • DNS lookups work in some locations but fail in others
  • The domain exists (you can access it in a browser) but Node.js cannot resolve it
  • Error occurs immediately without retries or delays
  • Other DNS record types resolve but specific types (A, AAAA, MX) do not
  • Works on different DNS servers but fails on yours
  • Error message shows 'no answers section' in detailed logs

Common causes

  1. Domain does not exist or has been deregistered
  2. DNS record of the requested type (A, AAAA, etc.) is not configured
  3. DNS propagation is incomplete (recently created domain)
  4. Wrong DNS server configured for that domain zone
  5. DNS records were deleted or misconfigured at the registrar
  6. Requesting wrong record type (e.g., AAAA for IPv6 when only A records exist)
  7. Split-horizon DNS returning different results in different networks
  8. DNS server cache contains stale empty responses
  9. DNSSEC misconfiguration causing validation failures
  10. Subdomain not properly configured at the registrar

How to fix "Error: NOTFOUND (no answers section)"

1Verify the domain exists and is accessible

First, confirm the domain is real and reachable:

bash
# Check if domain is accessible
curl -I https://example.com

# Or try to ping it
ping example.com

# Check domain registration
whois example.com

If the domain is accessible in a browser or via curl, but Node.js cannot resolve it, the issue is DNS-specific.

2Test with dig to see the actual DNS response

Use dig to see what the DNS server is actually returning:

bash
# Query A records
dig example.com A

# Query AAAA records (IPv6)
dig example.com AAAA

# Query with a specific DNS server
dig @8.8.8.8 example.com

# Get verbose output showing the answer section
dig +noall +answer example.com

If the answer section is empty, the DNS server has no records for that domain. Check if you're querying the correct record type or if the domain configuration is incomplete.

3Check DNS propagation status

New domains or recently changed DNS records may not have propagated globally:

bash
# Check DNS propagation using common DNS checkers
# Visit online tools:
# - https://www.whatsmydns.net/
# - https://dnschecker.org/
# - https://mxtoolbox.com/

# Or use command line
for ns in 8.8.8.8 1.1.1.1 208.67.222.222; do
  echo "Checking $ns:"
  dig @$ns example.com +short
done

If different DNS servers return different results, wait for DNS propagation to complete (can take 24-48 hours).

4Verify the domain is configured at your registrar

Check that DNS records are properly set up:

bash
# Get authoritative nameservers for the domain
dig example.com NS

# Query the authoritative nameserver directly
dig @ns1.example.com example.com

# List all records for the domain
dig example.com ANY

Log into your domain registrar (GoDaddy, Namecheap, Route 53, etc.) and verify:
- Nameservers are set correctly
- A/AAAA records exist for the domain
- CNAME records (if used) point to valid targets
- No conflicting or deleted records

5Try a different record type

The issue might be specific to the record type you're requesting:

javascript
const dns = require('dns').promises;

async function testAllRecordTypes(hostname) {
  const types = ['A', 'AAAA', 'MX', 'TXT', 'NS', 'SOA'];

  for (const type of types) {
    try {
      const records = await dns.resolveAny(hostname);
      console.log(`✓ ${type}: Found records`);
    } catch (err) {
      console.log(`✗ ${type}: ${err.code}`);
    }
  }
}

testAllRecordTypes('example.com');

If specific record types fail but others work, the domain configuration is incomplete for those types.

6Try using a different DNS server

Test if the problem is specific to your configured DNS server:

javascript
const dns = require('dns');

async function resolveWithDifferentServers(hostname) {
  const servers = [
    '8.8.8.8',      // Google
    '1.1.1.1',      // Cloudflare
    '208.67.222.222' // OpenDNS
  ];

  for (const server of servers) {
    dns.setServers([server]);
    try {
      const addresses = await require('dns').promises.resolve4(hostname);
      console.log(`✓ ${server}: ${addresses[0]}`);
      return addresses[0];
    } catch (err) {
      console.log(`✗ ${server}: ${err.code}`);
    }
  }
}

resolveWithDifferentServers('example.com');

If resolution works with public DNS but not your local/ISP DNS, the issue is with your DNS server's configuration.

7Check for DNS CNAME/redirect chains

If the domain uses CNAME records, verify the chain doesn't break:

bash
# Trace CNAME chain
dig example.com

# If it shows CNAME, trace to the target
dig target.example.com

# Repeat until you reach an A record
javascript
// Trace CNAME resolution
const dns = require('dns').promises;

async function traceCNAME(hostname) {
  try {
    const records = await dns.resolveCname(hostname);
    console.log(`CNAME: ${hostname} -> ${records[0]}`);
    return await traceCNAME(records[0]);
  } catch (err) {
    if (err.code === 'ENOTFOUND') {
      console.log(`Final target not found: ${hostname}`);
    } else {
      const addresses = await dns.resolve4(hostname);
      console.log(`A Record: ${hostname} -> ${addresses[0]}`);
    }
  }
}

traceCNAME('example.com');
8Implement error handling and fallback logic

Handle NOTFOUND gracefully and provide fallback options:

javascript
const https = require('https');

function fetchWithFallback(primaryDomain, fallbackDomain) {
  return new Promise((resolve, reject) => {
    https.get(`https://${primaryDomain}`, (res) => {
      resolve(res);
    }).on('error', (err) => {
      if (err.code === 'NOTFOUND') {
        console.warn(`DNS NOTFOUND for ${primaryDomain}, trying fallback...`);
        https.get(`https://${fallbackDomain}`, (res) => {
          resolve(res);
        }).on('error', reject);
      } else {
        reject(err);
      }
    });
  });
}

fetchWithFallback('old-domain.com', 'new-domain.com')
  .catch(err => console.error('All domains failed:', err.message));

Advanced notes

DNS Response Codes: The NOTFOUND error comes from DNS response code NXDOMAIN (Non-Existent Domain). Other DNS error codes include:
- NODATA (NOERROR + empty answer section)
- SERVFAIL (server failure)
- REFUSED (server refused query)

Node.js converts these to NOTFOUND when appropriate.

DNS Record Propagation: When you update DNS records, changes propagate through nameserver hierarchies. Even if your authoritative nameserver has the correct records, cached copies on other servers may be stale. TTL (Time To Live) values control how long caches hold records (typically 3600 seconds). Wait for TTL to expire before assuming propagation is complete.

Testing Specific Record Types: Different record types (A, AAAA, MX, etc.) can have different availability:

bash
dig example.com A      # IPv4 address
dig example.com AAAA   # IPv6 address
dig example.com MX     # Mail server
dig example.com TXT    # Text records (SPF, DKIM, etc.)

Only the record types you actually need must exist.

DNSSEC Validation: If DNSSEC is enabled, validation failures can appear as NOTFOUND. Test with DNSSEC disabled:

bash
dig +cd example.com  # Disable DNSSEC validation

Docker/Container DNS Issues: Containers may have different DNS servers than the host. Check container's /etc/resolv.conf:

bash
docker exec <container> cat /etc/resolv.conf

Difference from ENOTFOUND:
- NOTFOUND: Server responded with no records (domain doesn't exist)
- ENOTFOUND: Server didn't respond or couldn't be reached (timeout/unreachable)

NOTFOUND is faster to resolve (immediate response) while ENOTFOUND involves multiple retry attempts.

Custom DNS in Node.js: You can override default DNS servers at runtime:

javascript
const dns = require('dns');
dns.setServers(['8.8.8.8', '8.8.4.4']);

Changes apply to all subsequent DNS operations in that process.

Frequently asked questions

What does "NOTFOUND" mean?
js DNS operations indicates that a DNS query was successfully sent to and received by the DNS server, but the response contained no answer section. " This differs from ENOTFOUND errors which occur when the DNS server doesn't respond at all. With NOTFOUND, the DNS infrastructure is working—the server is reachable and responding—but it cannot provide the requested record.
How do I fix "NOTFOUND"?
The DNS NOTFOUND error occurs when a DNS server responds to a query but contains no answer records for the requested domain. This indicates the domain doesn't exist, is improperly configured, or the DNS server lacks the record information. This is different from timeouts or unreachable servers.
What causes "NOTFOUND"?
Domain does not exist or has been deregistered DNS record of the requested type (A, AAAA, etc.) is not configured DNS propagation is incomplete (recently created domain)
Is the "NOTFOUND" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading