Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1097513 of Host

  • Revision slug: Web/HTTP/Headers/Host
  • Revision title: Host
  • Revision id: 1097513
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment new page

Revision Content

{{HTTPSidebar}}

The Host request header specifies the domain name of the server (for virtual hosting), and (optionally) the TCP port number on which the server is listening.

If no port is given, the default port for the service requested (e.g., "80" for an HTTP URL) is implied.

A Host header field must be sent in all HTTP/1.1 request messages. A {{HTTPStatus("400")}} (Bad Request) status code will be sent to any HTTP/1.1 request message that lacks a Host header field or contains more than one.

Header type {{Glossary("Request header")}}
{{Glossary("Forbidden header name")}} yes

Syntax

Host: <host>:<port>

Directives

<host>
the domain name of the server (for virtual hosting).
<port> {{optional_inline}}
TCP port number on which the server is listening.

Examples

Host: developer.cdn.mozilla.net

Specifications

Specification Title
{{RFC("7230", "Host", "5.4")}} Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing

Browser compatibility

{{Compat}}

See also

  • {{HTTPStatus("400")}}

Revision Source

<div>{{HTTPSidebar}}</div>

<p>The <code><strong>Host</strong></code> request header specifies the domain name of the server (for virtual hosting), and (optionally) the TCP port number on which the server is listening.</p>

<p>If no port is given, the default port for the service requested (e.g., "80" for an HTTP URL) is implied.</p>

<p>A <code>Host</code> header field must be sent in all HTTP/1.1 request messages. A {{HTTPStatus("400")}} (Bad Request) status code will be sent to any HTTP/1.1 request message that lacks a <code>Host</code> header field or contains more than one.</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">Header type</th>
   <td>{{Glossary("Request header")}}</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Forbidden header name")}}</th>
   <td>yes</td>
  </tr>
 </tbody>
</table>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">
Host: &lt;host&gt;:&lt;port&gt;
</pre>

<h2 id="Directives">Directives</h2>

<dl>
 <dt>&lt;host&gt;</dt>
 <dd>the domain name of the server (for virtual hosting).</dd>
 <dt>&lt;port&gt; {{optional_inline}}</dt>
 <dd>TCP port number on which the server is listening.</dd>
</dl>

<h2 id="Examples">Examples</h2>

<pre>
Host: developer.cdn.mozilla.net</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Title</th>
  </tr>
  <tr>
   <td>{{RFC("7230", "Host", "5.4")}}</td>
   <td>Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p class="hidden">The compatibility table in this page is generated from structured data. If you’d like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data/README.md">https://github.com/mdn/browser-compat-data/README.md</a> and send us a pull request.</p>

<p>{{Compat}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{HTTPStatus("400")}}</li>
</ul>
Revert to this revision