On This Page
Step 1: DNS Lookup – Finding the Right Server
Step 2: TCP Handshake – Establishing a Connection
Step 3: HTTP Request & Response – Retrieving the Webpage
Step 4: Browser Rendering – Displaying the Page
Wrapping Up
FAQs

What Happens When You Type a URL? (Step-by-Step Explanation)

This blog breaks down the full web request lifecycle – from DNS lookup and connection handshake to the HTTP request/response and final page rendering.
Ever wondered what happens behind the scenes when you type a URL into your browser and press Enter?
Imagine you type www.example.com into your browser and almost instantly the site appears.
It seems like magic, but behind the scenes there's a flurry of network activity.
What really happens when you press Enter on that URL?
Let's find out together.
Step 1: DNS Lookup – Finding the Right Server
When you enter a URL (say, example.com) and hit Enter, the first thing your browser needs is the IP address of the server hosting that website.
Remember, computers don't directly understand names like "example.com" – they need a numerical IP address to locate the server.
This is where DNS (Domain Name System) comes in, often called the internet's phonebook.
The browser first checks if it already knows the IP address from a previous visit. It looks into multiple caches: the browser cache, your operating system cache, your router's cache, and your ISP's DNS cache.
If the address is found in a cache, great – it uses that IP immediately.
If not, the browser asks a DNS resolver (usually run by your ISP) to find the IP address for the domain.
This may trigger a recursive DNS lookup – the DNS resolver will query other servers on the internet until it finds the correct IP address for example.com. This whole lookup usually happens in milliseconds, so you barely notice it.
Step 2: TCP Handshake – Establishing a Connection
Now that your browser has the server’s IP address, it needs to connect to that server.
The browser does this by opening a TCP connection to the server’s IP on the appropriate port (port 80 for HTTP or port 443 for HTTPS). TCP (Transmission Control Protocol) is what ensures a reliable connection between your computer (the client) and the web server.
TCP uses a three-way handshake (SYN, SYN-ACK, ACK) to establish the connection.
If the site is using HTTPS (secure HTTP), an extra TLS handshake is performed to set up an encrypted channel. These handshakes happen quickly, and once they're done, the browser and server have a open line of communication.
Step 3: HTTP Request & Response – Retrieving the Webpage
Once the connection is established, your browser sends an HTTP request to ask for the page.
Typically, this is a GET request for the URL (for example, GET / HTTP/1.1
with a Host: example.com
header) to specify which page it wants. (Understanding HTTP basics like methods and headers is very useful, especially for interview prep!)
The server receives the request and sends back an HTTP response.
The response starts with a status code (e.g., 200 OK
meaning success) and headers (like Content-Type: text/html
to tell the browser it's getting HTML), followed by the webpage content (usually the HTML body).
In short, the server is saying, "Here is the page you asked for," and it delivers the data that the browser will use to display the site.
Step 4: Browser Rendering – Displaying the Page
Now the browser has to turn the received content into the webpage you see. It parses the HTML to build a DOM (Document Object Model) and applies any CSS styles.
As the browser processes the HTML, it may encounter references to other resources like images, CSS files, or JavaScript – for each of those, it makes additional requests (often in parallel).
Once all the needed pieces are loaded, the browser figures out the layout (where each element should go) and then paints the page on your screen, rendering the complete webpage.
In fact, modern browsers start to render content on the fly even before everything is fully loaded, so the page appears quickly and becomes interactive.
Wrapping Up
In summary, a lot happens in the blink of an eye when you type a URL and press Enter.
The browser finds the server via DNS, establishes a reliable connection with a TCP handshake (and secures it with TLS for HTTPS), sends an HTTP request, gets back an HTTP response with the page data, and then your browser renders the page for you. It's amazing how fast and transparent this process is to users.
FAQs
Q1: Why is DNS needed when you type a URL?
DNS is like the internet’s address book. It translates a website’s name into the server’s numeric IP address so the browser knows where to send your request.
Q2: What is a TCP handshake in simple terms?
A TCP handshake is a quick three-step exchange between your browser and the server to establish a reliable connection. It's basically both sides sending a few "hello" messages (SYN, SYN-ACK, ACK) to confirm they're ready to communicate.
Q3: How does the browser render a webpage after getting the data?
After receiving the page data, the browser builds a DOM (Document Object Model) from the HTML and applies any CSS styles. It then calculates where everything should appear and draws (renders) the page on your screen.
What our users say
KAUSHIK JONNADULA
Thanks for a great resource! You guys are a lifesaver. I struggled a lot in design interviews, and this course gave me an organized process to handle a design problem. Please keep adding more questions.
Nathan Thomas
My newest course recommendation for all of you is to check out Grokking the System Design Interview on designgurus.io. I'm working through it this month, and I'd highly recommend it.
Arijeet
Just completed the “Grokking the system design interview”. It's amazing and super informative. Have come across very few courses that are as good as this!