Interview Q&A / Computer Networks

BeginnerQuick answer1 min readUpdated 3 Oct 2026

Why does an HTTP/1.1 request need a Host header?

SHORT ANSWER

One server IP can host many websites. The TCP connection only carries the IP address, so the Host header tells the server which site the browser wants, letting it choose the right content. HTTP/1.1 requires it.

Explain it simply

A single apartment building (one IP address) has many shops inside. The street address alone does not say which shop you want, so you also say the shop's name. The Host header is that shop name.

Example

text
GET /index.html HTTP/1.1
Host: shop.example.com
bash
# Same IP, two different sites, selected only by the Host header
curl -H "Host: shop.example.com" http://203.0.113.10/
curl -H "Host: blog.example.com" http://203.0.113.10/

This is called name-based virtual hosting. It is why shared hosting can put thousands of sites on a few IPs, and why reverse proxies route by hostname.

For HTTPS the same problem happens earlier: the TLS handshake needs to choose a certificate before any HTTP request is sent. SNI solves that by sending the hostname in the ClientHello.

What to say in the interview

"Host selects the virtual host when many sites share one IP. HTTP/1.1 makes it mandatory. HTTP/2 carries the same information in the :authority pseudo-header, and TLS uses SNI for the same job."

Common mistakes

  • Thinking DNS alone tells the server which site was requested. DNS only gives the IP.

#http#host-header#virtual-hosting

Related questions

Practise more Computer Networks questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Computer Networks quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.