451 Unavailable For Legal Reasons

Officially, HTTP response status code 451 Unavailable For Legal Reasons is returned by the server to indicate that the content requested is unavailable due to a legal or legislated demand.

The response is cacheable by default. If the default behavior needs to be overridden then the response must include the appropriate HTTP caching headers.

In addition the HTTP status code 451 Redirect is also used by Microsoft Exchange ActiveSync when the client is attempting to connect to the wrong server, or if there is a more efficient server available to reach the user’s mailbox.

Usage

When the 451 Unavailable For Legal Reasons status code is received, the server is not confirming nor denying the existence of the resource. Rather, it indicates a refusal to grant access due to a legal demand, and it is permitted to state as much.

Essentially, the resource is being blocked due to censorship, and the HTTP status code pays homage to the Ray Bradbury novel about this topic, Fahrenheit 451.

Examples of where the 451 Unavailable For Legal Reasons response status applies will depend on the laws of the country from which it is being accessed. Some examples include copyright infringement, privacy violations, and gambling sites. Any situation where there is a court order, such as a publication ban, can use this HTTP status code. The 403 Forbidden response status is the more general version of the error.

The transparency afforded by this HTTP status code allows for the easier third-party collection of statistics related to the number, and perhaps a category of sites that are taken down due to censorship.

In some cases, clients can still access the resources by using alternative methods. For example, a VPN or the Tor network can be used to shroud one’s point of origin, or a proxy server can be used to redirect browser traffic to another country.

As part of the response, the server has to include a Link header that identifies the party that blocked the request. Importantly, this is the group responsible for blocking the content, and not the group who mandated it. Information about who set the policy can be included in the message body.

Note

Search engines like Google will not index a URL with 451 Unavailable For Legal Reasons response status, and consequently, URLs that have been indexed in the past but are now returning this HTTP status code will be removed from the search results.

Microsoft Exchange ActiveSync Usage

When the 451 Redirect error message is received, it means that the client is attempting to connect to the wrong server. This is either because the user’s mailbox cannot be accessed from this server or alternatively, there is a more efficient server than can be used.

If there is an X-MS-Location header included in the response then subsequent requests are required to use that address instead. If the X-MS-Location header is not included then the full Autodiscover process is followed.

Example

In the example, the client requests a resource and the server responds with the 451 Unavailable For Legal Reasons.

Request

GET /tech-trial-updates HTTP/1.1
Host: www.example.re

Response

HTTP/1.1 451 Unavailable For Legal Reasons
Link: <https://www.example.re/legaldept>; rel=”blocked-by”
Content-Type: text/html
Content-Length: 174

<html>
  <head>
    <title>Publication Ban</title>
  </head>
  <body>
   <p>The content that you have requested is unavailable due to a government-ordered publication ban.</p>
  </body>
</html>

Code references

.NET

HttpStatusCode.UnavailableForLegalReasons

Rust

http::StatusCode::UNAVAILABLE_FOR_LEGAL_REASONS

Rails

:unavailable_for_legal_reasons

Go

http.StatusUnavailableForLegalReasons

Symfony

Response::HTTP_UNAVAILABLE_FOR_LEGAL_REASONS

Python3.5+

http.HTTPStatus.UNAVAILABLE_FOR_LEGAL_REASONS

Apache HttpComponents Core

org.apache.hc.core5.http.HttpStatus.SC_UNAVAILABLE_FOR_LEGAL_REASONS

Angular

@angular/common/http/HttpStatusCode.UnavailableForLegalReasons

Takeaway

The 451 Unavailable For Legal Reasons status code is a client error that is sent by the server when the client requests a document for which access is not allowed by them or from within their geo location and/or locale.

In the case of 451 Redirect issued by Microsoft Exchange ActiveSync, it implies that the client is attempting to connect to the wrong server to access their mailbox.

See also

Last updated: August 2, 2023