Skip to Content
Mengty Learns
Foundations

Networking Basics: DNS, TCP, TLS, HTTP

How a browser resolves a hostname, opens a TCP connection, negotiates TLS 1.3, and exchanges HTTP requests and responses.

explanationbeginnerTested with curl 8.22.0Updated Nov 26, 2026

TL;DR

Loading an https:// URL is a layered handoff: DNS resolves the hostname to an IP, TCP establishes a reliable byte stream with a 3-way handshake, TLS 1.3 authenticates the server and encrypts the channel in 1-RTT, and HTTP exchanges requests and responses inside that tunnel.

Intent

TL;DR

Trace every network layer between typing a URL in a browser and receiving an HTTP 200 OK response, so you can pinpoint whether a failure is DNS, TCP, TLS, or HTTP.

Problem

When a web request fails or feels slow, "the network is down" is rarely actionable. Without knowing which layer runs first—name resolution, transport connection, encryption handshake, or application framing—it is hard to tell a NXDOMAIN lookup failure apart from a blocked TCP port, an expired TLS certificate, or a 502 HTTP gateway error.

Each layer depends on the one below it; a failure at DNS or TCP prevents TLS and HTTP from ever starting.

Solution

Each protocol solves one narrow job and hands off to the next:

  1. DNS (Domain Name System): The client asks a recursive resolver for the A (IPv4) or AAAA (IPv6) record of the hostname. Cached results are reused until their TTL expires.
  2. TCP (RFC 9293): The client opens a socket to the resolved IP on port 443 using the 3-way handshake (SYN → SYN-ACK → ACK), establishing sequence numbers for ordered, retransmitted byte delivery.
  3. TLS 1.3 (RFC 8446): Inside the TCP stream, ClientHello and ServerHello negotiate a cipher suite and Diffie-Hellman key share in 1-RTT, verify the server's X.509 certificate chain, and derive symmetric session keys.
  4. HTTP (RFC 9110): Once the TLS record layer is open, the browser sends an HTTP request (GET / HTTP/1.1 or HTTP/2 HEADERS frame) and the server returns status code, headers, and body back down the same TLS and TCP stack.

Real-world analogy

▶ Flow: watch it work

HTTPS Request Lifecycle: DNS → TCP → TLS 1.3 → HTTP

Overview of HTTPS Request Lifecycle: DNS → TCP → TLS 1.3 → HTTP. 8 steps.
Overview8 steps in this flow

Press Start or tap any step dot to trace the path.

▸All steps (8)

Code

You can observe each stage directly with curl -v (verbose output prints DNS resolution, TCP connect, TLS handshake, and HTTP headers):

# Inspect DNS, TCP connect, TLS 1.3 negotiation, and HTTP response headers (not run)
curl -vI --tlsv1.3 https://example.com

When to use / when to avoid

When to use
  • You are debugging latency or connection failures and need to isolate DNS, TCP, TLS, or HTTP.
  • You want to understand why connection reuse (HTTP keep-alive, HTTP/2 multiplexing) saves multiple round trips.
  • You are configuring load balancers, reverse proxies, or Kubernetes Ingress TLS termination.
When to avoid
  • You only need to check application-level JSON payloads; browser DevTools Network tab or curl -s is enough.
  • You are working inside a local Unix domain socket where DNS and TCP do not apply.

How to implement

Check DNS resolution first

Verify the hostname resolves to the expected IP (dig +short example.com or nslookup example.com).

Verify TCP reachability

Confirm the target IP and port (443) accept connections without firewall drops.

Inspect TLS certificate and version

Check that the server presents a valid certificate chain and negotiates TLS 1.2 or TLS 1.3.

Read the HTTP status and headers

Inspect the HTTP status code, Cache-Control, and Content-Type returned by the origin.

Pros / Cons

Pros
  • Clean separation of concerns: DNS, TCP, TLS, and HTTP evolve independently.
  • TLS 1.3 cuts handshake latency to 1-RTT (and 0-RTT for resumed sessions with replay caveats).
  • Standardized RFCs mean any compliant browser, CLI, or proxy interoperates.
Cons
  • Cold connections pay sequential round trips (DNS + TCP + TLS) before the first HTTP byte.
  • Head-of-line blocking in TCP delays all multiplexed HTTP/2 streams if one packet drops (why HTTP/3 uses QUIC over UDP).

Relations

Check yourself

Check Yourself

1. Which stage runs first when a browser has an empty cache and visits https://example.com?

2. How does TLS 1.3 improve handshake latency compared to TLS 1.2?

Sources