What Happens When You Type a URL in Your Browser
Typing a URL into the address bar and pressing Enter feels instantaneous. In reality, your browser, operating system, network stack, and multiple servers perform a carefully orchestrated sequence of steps to fetch and display a web page. Understanding this process gives developers a clearer mental model of the web, helps diagnose performance and connectivity issues, and builds stronger foundations for working with networking, security, and front-end performance.
This article walks through the full journey, from the moment you press Enter until the page appears on screen.
Simple Explanation
When you type a URL such as https://example.com/about and hit Enter, your browser needs to:
- Figure out the exact server that hosts the site.
- Open a reliable connection to that server.
- Ask the server for the specific page or resource.
- Receive the response (HTML, CSS, JavaScript, images, etc.).
- Parse and render the content so you can see and interact with it.
The process involves several layers of the networking stack and browser internals. Each layer has a clear responsibility, and problems at any layer can prevent the page from loading.
How It Works Internally
Here is the detailed technical flow.
1. URL Parsing
The browser first parses the string you typed. A typical URL looks like:
https://www.example.com:443/path/to/page?query=value#section
The browser extracts:
- Scheme (
https) — the protocol to use - Host (
www.example.com) — the domain name - Port (default 443 for HTTPS, 80 for HTTP)
- Path (
/path/to/page) - Query string and fragment (the fragment is handled only on the client)
If the scheme is missing, modern browsers usually assume https://. If the host looks incomplete, the browser may treat the input as a search query instead of a navigation.
2. DNS Lookup (Domain Name Resolution)
Computers communicate using IP addresses, not domain names. The browser therefore needs to translate www.example.com into an IP address such as 93.184.216.34.
The resolution process typically follows this order:
- Browser cache — recent lookups are stored in memory.
- Operating system cache — the OS maintains its own DNS cache.
- Local hosts file — a static mapping file on the machine.
- Recursive DNS resolver — usually provided by the ISP or a public resolver (1.1.1.1, 8.8.8.8, etc.).
The recursive resolver queries the DNS hierarchy:
- Root name servers
- Top-level domain (TLD) servers (
.com) - Authoritative name servers for
example.com
The answer returns one or more IP addresses (A records for IPv4, AAAA for IPv6). The browser may also receive additional records such as CNAME (canonical name) or TXT records.
DNS can use UDP (most common for small queries) or TCP. Modern systems also support DNS over HTTPS (DoH) or DNS over TLS (DoT) for privacy.
3. Establishing a TCP Connection
Once the IP address is known, the browser asks the operating system to open a TCP connection to the target IP and port.
TCP provides reliable, ordered delivery of data. The connection begins with the three-way handshake:
- Client → Server: SYN (synchronize)
- Server → Client: SYN-ACK
- Client → Server: ACK
After the handshake, the connection is ready to carry application data. For HTTPS, an additional TLS handshake occurs on top of the TCP connection. The TLS handshake negotiates encryption algorithms, authenticates the server via its certificate, and establishes shared session keys so that all subsequent data is encrypted.
Modern browsers often use HTTP/2 or HTTP/3. HTTP/2 still runs over TCP + TLS. HTTP/3 runs over QUIC, which uses UDP and incorporates its own connection and encryption handshake, reducing latency in many cases.
4. Sending the HTTP Request
With a secure connection established, the browser constructs an HTTP request. A simplified example for https://example.com/about looks like:
GET /about HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 ...
Accept: text/html,application/xhtml+xml,...
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Key points:
- The method is usually
GETfor page navigation. - The
Hostheader is required so the server knows which virtual host to serve when multiple sites share the same IP. - Additional headers convey browser capabilities, cookies, caching preferences, and security tokens.
Under HTTP/2 and HTTP/3 the request is binary-framed and can be multiplexed with other requests on the same connection, avoiding the head-of-line blocking that existed in HTTP/1.1.
5. Server Processing and Response
The request reaches a web server (or a reverse proxy / load balancer in front of it). The server:
- Matches the request to the correct application or static file
- Executes any server-side logic (routing, authentication, database queries, template rendering)
- Generates an HTTP response
A typical successful response begins:
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 12345
Cache-Control: max-age=3600
Set-Cookie: session=abc123; Path=/; HttpOnly; Secure
Followed by the response body (the HTML document).
Status codes communicate the outcome:
- 2xx — success
- 3xx — redirection
- 4xx — client error
- 5xx — server error
6. Receiving and Processing the Response
The browser receives the response headers and body. It examines the status code and Content-Type. For an HTML document it begins the rendering pipeline:
- Tokenization and parsing — the HTML is converted into a DOM (Document Object Model) tree.
- CSS parsing — stylesheets are fetched (if linked) and turned into a CSSOM.
- Render tree construction — DOM and CSSOM are combined.
- Layout (reflow) — the browser calculates the size and position of every element.
- Paint — pixels are drawn to the screen.
- Composite — layers are combined, especially when animations or transforms are involved.
While parsing the HTML, the browser discovers additional resources: CSS files, JavaScript files, images, fonts, etc. It issues new HTTP requests for each of them, often in parallel, subject to connection limits and prioritization rules.
JavaScript execution can block or modify the DOM and CSSOM, which is why script placement and loading attributes (async, defer, type="module") matter for performance.
7. Connection Management and Caching
Browsers keep connections alive (HTTP keep-alive or persistent connections) so subsequent requests to the same origin can reuse the existing TCP/TLS session. HTTP/2 and HTTP/3 further improve efficiency through multiplexing and header compression.
Caching occurs at multiple levels:
- Browser HTTP cache (controlled by
Cache-Control,ETag,Last-Modified) - Service Worker cache (if a progressive web app is installed)
- CDN and reverse-proxy caches
- DNS cache
A well-configured cache can turn a multi-round-trip process into a near-instant load from local storage.
Real-World Examples
Example 1 — First visit to a news site
You type https://news.example.com. DNS lookup is required, a full TCP + TLS handshake occurs, the HTML is fetched, then dozens of additional requests for stylesheets, scripts, images, and ads follow. The page may take several seconds on a slower connection.
Example 2 — Returning visitor
Many resources are already in the browser cache or served from a CDN with long cache lifetimes. The browser may only need to revalidate a few critical files, resulting in a much faster load.
Example 3 — Redirect
You type http://example.com. The server responds with 301 Moved Permanently and a Location: https://example.com header. The browser automatically issues a new request to the HTTPS URL and updates the address bar.
Example 4 — Single-page application
After the initial HTML and JavaScript bundle load, subsequent “page” changes are handled by client-side routing. The browser does not perform a full navigation; instead JavaScript fetches JSON data via fetch() or similar APIs and updates the DOM.
Common Misconceptions
“The browser just downloads the HTML file.”
Modern pages trigger many additional requests. The initial HTML is only the starting point.
“DNS is always fast and local.”
DNS lookups can involve multiple network round trips if the answer is not cached. DNS performance and reliability are significant factors in overall page-load time.
“HTTPS only adds encryption.”
TLS also provides server authentication (via certificates) and, with modern protocols, can improve performance through session resumption and 0-RTT data.
“Closing the tab immediately stops everything.”
In-flight requests may still complete or be cancelled depending on the browser and the stage of the request. Service workers and background fetches can continue independently.
“IP addresses never change.”
DNS records have TTLs. Load balancers and CDNs frequently change the IP addresses returned for a given hostname.
Best Practices and Key Takeaways
- Prefer HTTPS everywhere. Modern browsers and search engines expect it.
- Minimize the number of critical requests on the critical rendering path.
- Use appropriate cache headers so returning visitors benefit from local storage.
- Understand the difference between connection setup cost (DNS + TCP + TLS) and the cost of transferring the actual content.
- Measure real user performance with tools that capture the full navigation timeline (DNS, connect, TLS, TTFB, DOM content loaded, load event).
- When debugging, use the browser’s Network panel and look at the waterfall: DNS lookup, initial connection, SSL, request sent, waiting (TTFB), content download.
The sequence described above is the foundation of almost every web interaction. Mastering it helps you reason about latency, security, caching, and the trade-offs inherent in building fast, reliable web applications.
FAQ
What is the first thing that happens when I type a URL?
The browser parses the URL to extract the scheme, host, port, path, and other components.
Why does DNS lookup sometimes take a long time?
If the answer is not in any local cache, the recursive resolver must query multiple name servers across the internet.
What is the difference between HTTP and HTTPS in this process?
HTTPS adds a TLS handshake after the TCP connection is established, encrypting all application data and authenticating the server.
Does the browser make only one request for a page?
No. The initial HTML document usually triggers many additional requests for CSS, JavaScript, images, fonts, and other assets.
What is TTFB?
Time to First Byte — the time from the start of the request until the first byte of the response arrives. It includes DNS, connection setup, and server processing time.
Why do some sites redirect from HTTP to HTTPS?
Servers send a 301 or 302 response with a Location header pointing to the HTTPS version so that all traffic uses encryption.
Can the process be faster on subsequent visits?
Yes. DNS results, TCP/TLS sessions, and HTTP responses can be cached, dramatically reducing the work required.
What happens if the server is unreachable?
The TCP connection attempt times out or receives a reset, and the browser displays an error page (for example, “This site can’t be reached”).