All posts
networkingdnsdebugging

ERR_NAME_NOT_RESOLVED — What It Means and How to Fix It

"ERR_NAME_NOT_RESOLVED" explained — why it happens, a real code example that triggers it, and the exact fix.

SR

Suhail Roushan

August 6, 2026

·
3 min read
·
0 views

ERR_NAME_NOT_RESOLVED means the browser couldn't find the IP address for the domain you requested, so the connection failed before it ever started.

What "ERR_NAME_NOT_RESOLVED" Means

This is a DNS (Domain Name System) failure. Your browser asked a DNS resolver to translate a hostname like example.com into an IP address, and the resolver came back empty. No server was contacted, no TCP handshake happened — the request died at the DNS lookup stage.

Why It Happens

The three most common real causes are:

  1. Typo in the domain — you typed gogle.com instead of google.com. The DNS resolver has no record for it, so it returns NXDOMAIN.
  2. DNS server is down or misconfigured — your router or OS is pointing to a resolver that isn't responding, or your /etc/hosts file has a stale entry that shadows the real record.
  3. The domain genuinely doesn't exist — someone gave you a URL that was never registered, or its DNS records were deleted.

Example Code That Triggers It

In Node.js, this error surfaces when you make an HTTP request to a non-resolvable domain:

import { get } from "node:http";

// This domain does not exist — DNS lookup will fail
get("http://this-domain-does-not-exist-12345.com", (res) => {
  console.log(`Status: ${res.statusCode}`);
}).on("error", (err) => {
  // err.code === "ENOTFOUND" — Node's equivalent of ERR_NAME_NOT_RESOLVED
  console.error(`DNS resolution failed: ${err.code}`);
  console.error(err.message); // "getaddrinfo ENOTFOUND this-domain-does-not-exist-12345.com"
});

Run this and you'll see ENOTFOUND in the error object — that's Node's internal name for the same DNS failure Chrome reports as ERR_NAME_NOT_RESOLVED in the browser.

How to Fix It

The fix depends on which cause you're hitting. For a typo, correct the URL:

// Before (typo)
get("http://gogle.com", ...);

// After (correct)
get("http://google.com", ...);

For a broken DNS server, the fix is outside your code: flush your DNS cache (ipconfig /flushdns on Windows, sudo dscacheutil -flushcache on macOS) and check your resolver settings in /etc/resolv.conf (Linux) or your router's admin panel. Point to a known-good resolver like 8.8.8.8 or 1.1.1.1 temporarily to confirm.

Common Mistakes That Cause This

  1. Hardcoding environment-specific domains — I've seen devs hardcode localhost:3000 in API calls, then push to production where the resolver doesn't know that name. Use process.env.API_URL instead.
  2. Ignoring trailing periods or protocol mismatcheshttp://example.com. (trailing dot) is technically valid but often trips up naive parsers, and https:// on a domain with no TLS record will fail differently but still surface as a connection error.

When Should You Worry About This?

Worry when the error appears on a domain that worked minutes ago, or across multiple devices on the same network. That points to a DNS outage — either your provider's resolver is down or the domain's authoritative nameservers are failing. If it's only on your machine, it's a local cache or config issue. If it's everywhere, check the domain's DNS health with a tool like dig or nslookup before touching your code.

First thing to check: run nslookup <domain> in your terminal — if that fails, it's DNS, not your code.

Related posts

Written by Suhail Roushan — Full-stack developer. More posts on AI, Next.js, and building products at suhailroushan.com/blog.

Get in touch