🎉 Requestly joins BrowserStack to build the future of application testing. Read more

HTTP Headers

Host

HTTP Header

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.

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.

Example

http
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:

  1. Install and open the Requestly Chrome extension. You can find it on the Chrome Web Store.
  2. Create a new rule: Click on “Create Rule” and choose “Modify Headers” from the list of available rule types.
  3. 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).
  4. Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-api.com/*).
  5. 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.