511 Network Authentication Required

HTTP response status code 511 Network Authentication Required is a server error used by captive portals to inform HTTP clients that they need to complete a sign-in after connecting to a network.

Usage

When the 511 Network Authentication Required status code is received, it is being used to inform the HTTP client that it needs to log in before being granted access to the network. An example of a captive portal is a hotel portal granting their guests access to non-public Wi-Fi services.

The use of the 511 Network Authentication Required status code is used so that HTTP clients will know that the HTTP response is not coming from the origin server. Rather, it is coming from a gatekeeper.

Example

In the example, the HTTP client requests a resource and the server responds with a 511 Network Authentication Required status code because the HTTP client must first authenticate before being granted regular access to the network.

Request

GET / HTTP/1.1
Host: www.example.re

Response

HTTP/1.1 511 Network Authentication Required
Content-Type: text/html; charset=UTF-8
Content-Length: 199

<html>
  <head>
    <title>Network Authentication Required</title>
  </head>
  <body>
    <p>Before accessing this service, you must <a href="https://login.example.re/">Login</a>.</p>
  </body>
</html>

Code references

.NET

HttpStatusCode.NetworkAuthenticationRequired

Rust

http::StatusCode::NETWORK_AUTHENTICATION_REQUIRED

Rails

:network_authentication_required

Go

http.StatusNetworkAuthenticationRequired

Symfony

Response::HTTP_NETWORK_AUTHENTICATION_REQUIRED

Python3.5+

http.HTTPStatus.NETWORK_AUTHENTICATION_REQUIRED

Apache HttpComponents Core

org.apache.hc.core5.http.HttpStatus.SC_NETWORK_AUTHENTICATION_REQUIRED

Angular

@angular/common/http/HttpStatusCode.NetworkAuthenticationRequired

Takeaway

The 511 Network Authentication Required status code informs the HTTP client that it has reached a captive portal and must authenticate before being granted access to the network.

See also

Last updated: August 2, 2023