Host
The HTTP Host request header specifies the host and port number of the server to which the request is being sent.
If no port is included, the default port for the service requested is implied (e.g., 443 for an HTTPS URL, and 80 for an HTTP URL).
A Host header field must be sent in all HTTP/1.1 request messages.
A 400 Bad Request status code may be sent to any HTTP/1.1 request message that lacks or contains more than one Host header field.
Note: The Host header is essential for the server to identify the target resource, especially when multiple domains are hosted on a single IP address. Proper implementation ensures correct routing and security.
Syntax
Host: <host>:<port>
Directives
The server’s domain name specifies the host, used for virtual hosting purposes. It determines which website or service the server provides. The port number indicates the specific TCP port on which the server listens for incoming connections. If the port is not specified, a default port is typically assumed based on the protocol used.
Note: These directives are used in configuring server behavior and are essential for directing traffic correctly within a network.
Examples
Host: developer.mozilla.org
How to Modify Header using Requestly
Requestly is a powerful Chrome extension that allows you to modify HTTP headers, including the Host header. This is especially useful for testing how your application behaves when requests come from different domains or servers. Steps to Modify the Host Header:
- Install and open the Requestly Chrome extension. You can find it on the Chrome Web Store.
- Create a new rule: Click on “Create Rule” and choose “Modify Headers” from the list of available rule types.
- Add a new header modification:
- Under “Action”, select “Add” or “Override”.
- In the “Header Name” field, enter Host.
- In the “Header Value” field, enter the desired host value (e.g., example.com).
- Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-api.com/\*).
- Save the rule.
Once set up, Requestly will inject the modified Host header into all matching requests, allowing you to test server routing, virtual hosting setups, or bypass restrictions tied to specific hostnames. Modifying the Host header can be useful when you want to test how your server responds to requests intended for different domains or troubleshoot issues related to domain-based routing. It helps mimic requests coming from various hosts without needing to change your actual DNS or server configuration.
Set headers visually: intercept and modify HTTP headers without touching your code using Requestly.
Download Free →