511 Network Authentication Required
Meaning
The client needs to authenticate to gain network access. Typically seen in captive portal scenarios where a user must login to a network before proceeding.
When to Use
When an intermediary (like a Wi-Fi hotspot or corporate network gateway) intercepts requests and requires the user to authenticate or accept terms before allowing internet access. The proxy uses 511 to notify the client that it should prompt the user to log in to the network.
Example
When connecting to a public Wi-Fi, the first HTTP request might be met with 511 Network Authentication Required, causing the browser to redirect to a login/portal page for credential input, after which normal access is granted.
When Not to Use
Do not use for ordinary application authentication (use 401 for that). 511 is not for APIs or websites requiring login; it's specifically for network access control scenarios by intercepting proxies/gateways.
Source
RFC 6585