What is the Host header?
The Host request header names the domain (and optional port) of the server the request targets. It is mandatory in HTTP/1.1: every request must include exactly one Host header so the server knows which host the client intends to reach.
API Usage & Best Practices
- Enables virtual hosting: Multiple domains can share one IP address because
Hostdisambiguates which site or API the request is for. - Missing or duplicate values fail: An HTTP/1.1 request without a
Host, or with more than one, must be answered with400 Bad Request. - Ties to 421: If a server receives a request for a host it cannot serve on that connection, it may respond with
421 Misdirected Request.
Examples
GET /v1/users HTTP/1.1Host: api.example.com:443