| Status code | 511 |
|---|---|
| Status text | Network Authentication Required |
| Category | 5xx Server Error |
| Response has body | Usually |
| Specification | RFC 6585 |
What does 511 Network Authentication Required mean?
The network you are on wants you to sign in before it will let traffic through. It belongs to the 5xx Server Error class, which means the server failed to fulfil an apparently valid request. The problem is on the server side.
When do APIs return 511?
On hotel, airport and café Wi-Fi with a captive portal. The response is generated by the network's gateway, not by the site you asked for, and its body is normally a login page.
How to fix a 511 Network Authentication Required
Open a browser, complete the network's sign-in page, then try again. For software, the danger is mistaking the portal's reply for the real one: a client that sees 511, or HTML where it expected JSON, should report that the network is not yet open and should not parse the body as if the API had sent it.
Reproduce a 511 response
The fastest way to understand a status code is to trigger one and read the full response. Open the
API tester and send a request to https://httpbin.org/status/511 — you will
see the 511 status along with every response header the server sent. Comparing those headers against
a working request is often what reveals the cause.
When you are debugging a real endpoint, check the response headers as carefully as the body, and confirm you are using the right HTTP method for the operation.
Related 5xx status codes
500 Internal Server Error
The server hit an unexpected condition and could not complete the request.
501 Not Implemented
The server does not support the functionality required to fulfil the request.
502 Bad Gateway
A server acting as a gateway or proxy received an invalid response from the upstream server.
503 Service Unavailable
The server is temporarily unable to handle the request.
504 Gateway Timeout
A gateway or proxy did not receive a timely response from the upstream server.
505 HTTP Version Not Supported
The server does not support the major HTTP version named in the request.
See also
- 407 Proxy Authentication Required — A proxy between you and the server wants credentials before it will forward the request.
- 401 Unauthorized — The request lacks valid authentication credentials. Despite the name, this means unauthenticated.
References
- RFC 6585 — The specification that defines this status code.
- MDN: 511 Network Authentication Required — MDN's reference page for this status code.