DNS and HTTP work together in one fixed order: DNS turns a human-readable domain name into an IP address your machine can route to, and only then does HTTP carry the actual page request over that address. The browser cannot send a single HTTP byte until the name lookup finishes. Any HTTP exchange you see in developer tools sits behind at least one DNS resolution β€” usually several β€” and that ordering is what makes a slow DNS server feel like an entire site being slow.

The two protocols sit at different layers and do different jobs, which is why they never overlap: DNS answers "where is this server?" and HTTP answers "what do you want from it, and here it is." Everything that goes wrong on a website load sorts into one of those two buckets, and knowing which bucket you're in cuts diagnosis time in roughly half. What follows walks the whole chain in performance order, then covers TTLs, failures, and the costs that determine whether your page shows up in 40 milliseconds or three seconds.

The Division of Labor: A Phone Book Lookup Behind Every Page Request

DNS is a distributed naming database. HTTP is an application protocol. That's the whole difference, and it explains why a site can resolve perfectly and still return an error, or return fine on a network where naming is broken.

HTTP follows the request-response model published as RFC 9110 by the IETF, the body that maintains internet standards. The browser sends a method (usually GET), a path, and headers, and the server returns a status code plus a body. DNS has its own separate specification, RFC 1034 and RFC 1035, which define a hierarchical database queried with a simple ask-and-answer packet.

The practical consequence is that DNS queries travel over UDP on port 53 by default, while HTTP travels over TCP on port 80 or, in modern practice, over TLS on port 443. Two different transports, two different failure modes, two different caching models.

Think of DNS as a phone book that changes addresses daily and HTTP as the conversation you have once you've dialed the number. If you call the wrong number, no amount of clear speaking helps.

What Actually Happens Step by Step, From Address Bar to Rendered Page

Here is the sequence in the order the browser performs it. Each step must complete before the next begins, though modern browsers overlap and pre-fetch aggressively to hide the waiting.

1: Cache check (local). The browser checks its own DNS cache, then the operating system resolver cache. On Windows, run ipconfig /displaydns in Command Prompt to see it. A hit skips everything from step 2 to step 5. 2: Recursive resolver query. Your machine asks the resolver configured in your network settings β€” often your ISP's, or a public one like Cloudflare's 1.1.1.1 or Google's 8.8.8.8. 3: Root and TLD referral. If the resolver has nothing cached, it asks a root server, which refers it to the authoritative server for the top-level domain (.com, .org, .uk). That server refers it to the domain's own nameservers. 4: Authoritative answer. The domain's nameserver returns the A record (IPv4) or AAAA record (IPv6), plus a TTL in seconds telling everyone how long to cache it. 5: TCP and TLS handshake. The browser opens a connection to the returned IP on port 443 and negotiates encryption. 6: HTTP request and response. The browser sends GET / with headers; the server returns a status line, headers, and HTML, which the browser parses and repeats for every subresource.

The failure handling matters as much as the happy path. If step 2 times out after the resolver's retry window (typically a few seconds), the browser shows a DNS error and never reaches step 5. If step 5 fails β€” a refused connection or a certificate mismatch β€” you get a TLS or connection error even though naming succeeded. The two error screens are diagnostics, and they tell you which half of the chain broke.

One Worked Example With Real Milliseconds: How Long Each Stage Costs

The clearest way to see the two protocols cooperating is to count time. Using published latency figures, a cold load of a simple site looks like this.

Stage Protocol Typical cold-start cost Typical warm cost
OS and browser cache check DNS (local) under 1 ms under 1 ms
Recursive resolver, cache miss DNS 20–120 ms 0 ms (cached)
Authoritative round trip DNS 20–80 ms added 0 ms
TCP handshake Transport for HTTP 1 RTT, roughly 10–150 ms reused connection, 0 ms
TLS handshake TLS for HTTPS 1–2 RTT, roughly 20–200 ms resumed session, near 0 ms
HTTP request to first byte HTTP 50–500 ms, server-dependent varies

According to Cloudflare's published documentation on DNS resolution, a full uncached lookup typically adds 20–120 milliseconds before any HTTP traffic begins. Google's own web performance guidance, published through its web.dev property, treats each network round trip as a fixed tax and recommends keeping critical-path round trips low for exactly this reason.

Run the arithmetic. For a single cold visit, DNS adds roughly 20–120 ms, TCP adds one round trip, TLS adds one or two more. That is between two and four round trips before the first HTTP byte moves. On a 50 ms round-trip connection, that's 100–200 ms of pure setup β€” enough to matter on a page that otherwise loads in 400 ms.

Warm, none of it costs anything. The same user returning within the TTL pays zero DNS and often zero handshake cost, which is why repeat visits feel dramatically faster than first ones.

Caching at Both Layers Is What Makes Repeat Visits Feel Instant

DNS and HTTP each run their own cache with its own expiry rule, and confusing them causes real misdiagnosis. A DNS TTL of 300 seconds and an HTTP Cache-Control: max-age=3600 are two independent clocks.

For DNS, the TTL comes from the authoritative record and is measured in seconds. Cloudflare's default for proxied records is 300 seconds (Auto), and the platform's documentation explains that lower values speed up propagation of changes at the cost of more queries. That tradeoff is the whole DNS caching story in one sentence.

For HTTP, the server declares freshness with Cache-Control. A static image might carry max-age=31536000 (one year), while an HTML page might use no-cache, forcing revalidation through an ETag or Last-Modified check. The MDN Web Docs entry on HTTP caching describes the full behavior, including how stale-while-revalidate serves a stale copy while fetching a fresh one.

Where people get it wrong: changing an A record does nothing to browsers holding a cached copy of the page itself, and clearing the browser cache does nothing to a stale DNS entry on the operating system. You have to flush both. Windows takes ipconfig /flushdns; macOS and Linux depend on the resolver service in use.

The overlap that matters for performance: DNS caching and HTTP connection reuse compound. A browser that holds an open HTTP/2 connection and a cached DNS entry can issue a new request with effectively zero setup.

Why HTTP/3 Changed the Stack: The DNS Hint That Skips a Handshake

HTTP/3, standardized as RFC 9114 by the IETF in June 2022, runs over QUIC instead of TCP. That shift directly changes how DNS and HTTP cooperate, because QUIC collapses the transport and encryption handshakes into one step.

On HTTP/2 over TCP with TLS, a new connection needed a TCP handshake (one round trip) plus a TLS handshake (one or two more). QUIC combines them, so a fresh HTTP/3 connection costs one round trip total before the request goes out. Add the DNS lookup in front and a cold HTTP/2 load costs three to five round trips before the first byte, while a cold HTTP/3 load costs two to three.

There's a DNS-level companion to this. The HTTPS resource record type, defined in RFC 9460, lets the DNS answer itself advertise that a host supports HTTP/3, so the browser doesn't have to discover it by trial. That's the two protocols cooperating at a deeper level than simple address lookup.

Per Cloudflare's published HTTP/3 documentation, the protocol also survives network changes better β€” a phone switching from Wi-Fi to cellular keeps the connection alive, where TCP would drop it and force a fresh DNS-and-handshake cycle. If your users are mobile, that's a concrete reliability gain, not a theoretical one.

A DNS Failure Case That Looks Exactly Like an HTTP Outage

The most instructive failure is the one where everything downstream is healthy and the site still won't load. Picture a domain whose A record was changed at the registrar but whose old record had a TTL of 86,400 seconds β€” one day.

Some resolvers still hold the old address, so their users connect to a server that no longer serves the site. Those users see a 404 or a connection refused, which is an HTTP-layer error, while others see the site fine. The HTTP layer reporting "404" has nothing to do with HTTP being broken. It reached the wrong server because DNS handed out a stale address.

The other classic: a misconfigured CNAME pointing to a host that has no A record. The resolver returns NXDOMAIN, the browser shows a name-resolution error, and no HTTP request is ever attempted. Support tickets describing "the site is down" arrive alongside colleagues who load it without issue, and the split correlates exactly with which resolver each person's network uses.

Diagnosis path: run nslookup example.com or dig example.com and check the returned address, then compare it against what the hosting provider reports. If those differ, you're in the DNS half and HTTP is a bystander. If they match and the page still fails, move to the HTTP half and check status codes and certificates.

The lesson: always establish which layer answered before changing anything. Restarting the web server when the record is stale wastes an hour and fixes nothing.

Status Codes and TTLs Tell You Which Protocol Owned the Fault

Reading errors correctly depends on knowing which layer produced them, and the status codes are unambiguous once you know the mapping. HTTP status codes come in five classes per RFC 9110: 1xx informational, 2xx success, 3xx redirect, 4xx client error, 5xx server error.

DNS has no status codes in the HTTP sense. It has response codes in the header β€” NOERROR, NXDOMAIN, SERVFAIL, and REFUSED β€” and each maps to a different visible browser failure. NXDOMAIN means the name doesn't exist. SERVFAIL means a resolver failed to get an answer, often a DNSSEC validation problem or an unreachable authoritative server. REFUSED means a resolver declined the query, usually a policy or rate-limit block.

Match the symptom to the layer:

What you see Likely layer First check
"Server IP address could not be found" DNS nslookup the hostname
ERR_NAME_NOT_RESOLVED in Chrome DNS resolver settings, then record existence
404 or 410 HTTP URL path, server routing
502 or 504 HTTP upstream server health and timeouts
ERR_CONNECTION_REFUSED Transport port listening, firewall
Certificate warning TLS certificate chain and expiry date

The rule of thumb: if the browser never mentions an address, the fault is upstream of HTTP. If it has an address and still complains, DNS did its job and something later in the chain failed.

The Cost of Getting It Wrong: Measured Delays and Their Causes

Latency here is not abstract. Each cold DNS lookup and each unneeded handshake is a measurable delay on every first visit, and the fixes are known and cheap.

Public resolver performance is documented. Cloudflare publishes that 1.1.1.1 resolves queries across its global anycast network, and the company has publicly reported median query times well under 20 milliseconds for users near its points of presence β€” the exact figure varies by location, so confirm current numbers on Cloudflare's own site rather than trusting a quoted value.

The biggest avoidable cost is a long chain of subresource lookups. If a page pulls assets from eight different hostnames, that's eight separate DNS resolutions on a cold visit, each potentially 20–120 ms. Consolidating onto fewer hostnames, or using and hints, removes most of that stack. Google's web.dev guidance documents both hints as standard practice for exactly this reason.

A worked calculation from the table above: eight cold lookups at a 60 ms average add 480 ms before any asset downloads. Cut it to two hostnames and you save 360 ms on every first visit β€” for free, with no server change. That number is why hostname consolidation shows up in almost every performance audit.

On the HTTP side, the cost concentrates in handshakes. Reusing one HTTP/2 connection for all requests to a host removes the per-request TCP and TLS cost entirely, which is why splitting assets across many domains β€” a 2010-era trick β€” now backfires.

What the Browser Does in Parallel, and Where It Still Waits

Modern browsers don't strictly run the chain one request at a time; they pipeline aggressively, and understanding the overlap changes what you optimize.

When the HTML arrives, the browser's preload scanner reads ahead and starts DNS lookups and connection setup for subresources it finds in the markup β€” often before the parser has finished the page. This means DNS for a stylesheet host can begin while the main document is still downloading. That overlap is why parallel work matters more than tightening any single step.

The hard wait is the first one. Nothing preloads before the initial HTML arrives, so the DNS lookup for the main document is always on the critical path with no overlap. That single lookup is the least hideable cost on the page and the one most worth caching well.

Connection limits still apply: browsers cap concurrent connections per hostname, though HTTP/2 and HTTP/3 multiplex many requests over one connection and largely dissolve the cap. The practical guidance is unchanged β€” reduce the number of distinct hostnames so the DNS and connection work stays small.

If you're debugging a slow load, open DevTools, go to the Network panel, and sort by "Start time." The first entries will be the document's DNS and connection, and their duration tells you whether your problem is naming speed or server speed.

FAQ

Does DNS happen before HTTP on every request, or only the first time?

It happens before every request, but on repeat requests it's usually served from cache in under a millisecond. Your operating system and browser hold resolved addresses for the record's TTL, so a second visit within that window skips the recursive lookup entirely. Once the TTL expires, the full query runs again. The dependency never disappears β€” only the wait does.

Why does a site load fine for me but show a DNS error for a coworker?

The most common cause is resolver divergence: the two of you use different recursive resolvers or different cache states. One holds a fresh or correct record and the other holds a stale or broken one. A secondary cause is split-horizon DNS, where internal and external networks are deliberately given different answers. Comparing nslookup output on both machines settles it in under a minute.

Can an HTTP error ever be caused by DNS?

Yes, in the specific case of a stale or wrong-but-valid address. DNS delivers a routable IP that points at the wrong server, so the HTTP exchange completes and returns a 404 or 403 from a machine that isn't the one you intended. That's technically an HTTP status, but the root cause is the naming layer. Checking whether the resolved address matches the hosting provider's published address is the fast test.

Does HTTP/3 remove the need for DNS?

No. HTTP/3 still needs an address to connect to, so DNS resolution still runs first. What changes is the shape of the wait: QUIC merges transport and encryption setup into fewer round trips, and the HTTPS DNS record type can advertise HTTP/3 support so the browser skips trial-and-error. The lookup is still there; the handshake after it is just shorter.

What TTL should I set when I'm about to change a server's address?

Drop the TTL to 300 seconds or lower at least one full old-TTL period before the change. If your current TTL is 86,400 seconds, that means lowering it a day ahead so resolvers have picked up the short value before you switch. Keep it low for a day after the change, then raise it back. Cloudflare's documentation recommends this exact sequence for planned migrations.

Is a 502 error a DNS problem?

Almost never. A 502 means your browser reached a server and that server failed to get a valid response from an upstream it depends on. DNS already did its job β€” you got an address and connected. The fault is inside the HTTP and server tier, typically a dead backend process or a timeout, and the fix lives there rather than in your records.

How much time does a cold DNS lookup actually add to a page load?

For most users, 20–120 milliseconds, per Cloudflare's published resolution figures. On a fast connection near a resolver's point of presence it trends toward the low end; on a long-haul or congested path it trends high. Multiply by the number of distinct hostnames on the page to see the real total, because each one pays its own cold cost.

Does clearing my browser cache fix a stale DNS record?

No. Browser cache and DNS cache are separate stores maintained by different software. Clearing the browser's cached pages and images leaves the operating system's resolved addresses untouched. You need the resolver flush command β€” ipconfig /flushdns on Windows, or the equivalent for your platform's resolver service β€” and sometimes a browser restart as well.

The chain is fixed and worth memorizing: name lookup, address in hand, connection, encryption, request, response, render. Every slowdown and every error message falls into one of those stages, and the stage determines the fix. Cache what you can at both layers, keep hostnames few, and let HTTP/3 shorten the tail.