511

Network Authentication Required

Overview

511 Network Authentication Required means the client must authenticate to gain network access. The classic case is the "captive portal" login page you see on public Wi-Fi in cafes, airports, and hotels.

Crucially, this code comes not from your intended destination server but from the network equipment (the captive portal) intercepting traffic in between. It means you have not yet logged in or accepted the network's terms — not that the site you wanted has a problem.

When it happens

Request / Response example

Request
GET http://example.com/ HTTP/1.1
Host: example.com
Response
HTTP/1.1 511 Network Authentication Required
Content-Type: text/html

<html><head><meta http-equiv="refresh" content="0; url=https://wifi.airport.example/login"></head>
<body>You need to sign in to this Wi-Fi network.</body></html>

In code

// A captive portal intercepts traffic until the client signs in
app.use((req, res) => {
  if (!isAuthenticatedOnNetwork(req)) {
    return res.status(511).type('html')
      .send('<meta http-equiv="refresh" content="0; url=/portal/login">');
  }
});

Common causes

How to fix

Notes

Related status codes

Related headers

Specification