What Happens When You Enter a URL — DNS, HTTP, and HTTPS

This article is part of the IT Foundations course, which builds up from scratch the practical IT knowledge you need at a minimum for programming and vibe coding.
A URL can be read as four parts. The diagrams follow DNS, which turns a name into a number, HTTP, which fetches the content, and HTTPS, which keeps it from being read along the way.

This article covers what happens between entering a URL and the screen appearing.

Three things come up: DNS, which turns a name into a number; HTTP, which exchanges the content; and HTTPS, which keeps that traffic from being read.

The single line you typed is split into four parts
http://localhost:3000/reserveStarthttpMiddlelocalhostNumber:3000End/reserveWhich rules itis sent underWhich computerWhich programWhich page
The top is the line you typed. The middle row is its parts, and the bottom row is what each one answers. It takes all four together to settle where to send what.

It takes all three together to settle where to send what.

A URL is a string that points to which page on which computer

The string you type in the instructions is a URL (Uniform Resource Locator), a single line that points to which computer the page you want is on, and where it is on that computer.

What is inside a single URL
One URL line (http://localhost:3000/reserve)
Start — http
  • This part is everything before the "://"
  • If this is https, what you send is encrypted
Middle — the domain name
  • A human-readable name given to a computer on the Internet
  • A public server gets a name such as example.com
  • localhost, used locally, is a fixed name for the computer it is typed on
  • This settles which computer the request goes to
Number — the port number
  • The number saying which program inside one computer the request goes to
  • Several programs can wait for requests at once, so this number picks one
  • http is fixed at 80 and https at 443, so those numbers are left out
End — /reserve
  • Starting with "/", the position of a page within the same server
  • Leave it out and you get that server's entry page
The outer frame is the single line http://localhost:3000/reserve. From the top: the rules for sending, which computer, which program inside it, and which page.

It is the browser itself that splits the line into these four parts.

Read a URL in four parts

A URL is one line joining four parts.

The start is the rules for sending, the middle is which computer, the number is which program inside it, and the end is which page; a local URL and a public URL are made of the same four parts, differing only in the characters they hold.

From entering a URL to the screen appearing — DNS and HTTP

The IP address seen in the previous article is that number.

The rules for looking up an IP address from a domain are DNS (Domain Name System), and the rules by which a browser and a server exchange requests and responses are HTTP (HyperText Transfer Protocol).

The machine that holds the DNS mappings and answers queries is the DNS server.

What the browser sends is the request and what comes back is the response, and between entering a URL and the screen appearing, the browser connects to two parties in turn.

The browser connects to two parties in turn
Browser① Ask the DNSserver about the nameOnly the number203.0.113.5The page contentdoes not come back② Connect tothat numberLook at /reserve,pick what to returnThe page contentcomes back
From the browser on the left it splits into an upper and a lower line. The upper one is the first party, the DNS server, and the lower one is the second, the Web server; what comes back differs.

The order is: first turn the name into a number, then go and fetch the content.

The DNS server you connect to first returns only a number; it does not return the page content.

The content is held by the server you reach at that number, which looks at /reserve at the end of the URL before picking what to return.

On the same server, /reserve and /login pick out different content.

The response that comes back holds a three-digit number and the page content, and what appears on screen is only the content file.

Turn the name into a number, then get the content

The browser does four things: reads, asks, receives, and draws.

It splits the URL you typed into four parts, asks the DNS server for the number, and requests the page at that number.

The server looks at the end of the URL, picks what to return, and returns it along with a number saying whether it went well.

HTTPS is the rules that keep the content from being read in transit

In traffic that starts with http, the characters you typed travel as they are, so devices along the way can read the content.

What prevents this is HTTPS (HyperText Transfer Protocol Secure), which exchanges what you send after encryption, converting it into a form that nobody but the intended party can turn back into the original.

With the same characters, http and https differ in what is visible along the way
You typedpassword123Sent over httpDevices on the pathread it as isThe server readswhat you typedSent over httpsDevices see onlythe destination nameThe server turns itback and reads it
On the left are the same typed characters. The upper path is http and the lower path is https. The characters the server reads are the same in both; only the path in the middle differs.

The characters the server reads are the same in both; what differs is only what devices along the way can see.

Even with https, which server the traffic is addressed to is visible along the way.

What is not visible is which page you opened and what you typed.

In one https exchange, what the path can tell and what it cannot
One exchange sentover httpsWhat devices on thepath can tellWhat devices on thepath cannot readThe destinationexample.comThe typed password,the page contentWhich site you visitedis recordedEven if seen, thecontent is unreadable
The single exchange at the top splits left and right. Only the left is visible to devices along the way; the right is not. The bottom row is what follows from that.

HTTPS also includes a mechanism for confirming that the other side owns that domain.

The certificate is issued not by the server itself but by a certificate authority (CA), a third party that verifies who owns a domain and issues certificates.

Inside the certificate is the public key used to confirm that the other side is genuine — a key that may be handed to anyone.

Confirming comes first, and encryption comes after.

The key is made only after the other side is known to be the owner, so even if a device in between intercepts the traffic, it cannot read the content.

https keeps the content from being read

The difference between http and https is only whether the content can be read along the way.

With http the characters travel as they are, so devices along the way can read the content; with https the characters are converted before sending, so all the path can tell is the destination name.

QUIZ

Knowledge Check

Answer each question one by one.

Q1In the http://localhost:3000 given in the instructions, which computer does localhost point to?

Q2Which mechanism takes a domain such as example.com and looks up the IP address used for communication?

Q3What is the difference between a URL starting with https and one starting with http?