RFC 6585: Additional HTTP status codes

Summary

In April 2012, Mark Nottingham and Roy Fielding added four status codes to HTTP in RFC 6585: 428, 429, 431 and 511. They name situations for which servers previously had to use unsuitable codes, from lost updates to rate limiting to login pages in hotel Wi-Fi. The ten-page document is an example of how small standards noticeably improve everyday operation.

Four codes for four everyday problems

428 Precondition Required demands conditional requests. This lets a server prevent the lost update problem, in which a client reads a state, modifies it and writes it back although someone else has changed it in the meantime. 429 Too Many Requests reports that a client has sent too many requests and may state with Retry-After when it should try again.

431 Request Header Fields Too Large rejects requests with headers that are too large, individually or in total. In practice this often hits browsers with too many or too large cookies.

511 and login pages

511 Network Authentication Required is intended for captive portals, that is, networks that only allow access to the internet after login or acceptance of terms of use. The code must not come from the actual website but only from the device controlling access, and it must not be cached.

The response should only link to the login page, not contain the form itself, so that browsers do not associate the login with the originally requested address. This is meant to prevent clients from mistaking the login page for the real page or storing it under its address.

Ideas

  • 428 enforces conditional requests against lost updates.
  • 429 reports too many requests and can name Retry-After.
  • 431 rejects headers that are too large.
  • 511 signals that the network requires login.
  • 511 comes from the access device, not from the website.
  • Responses with 511 must not be cached.

Insights

  • Precise error codes make automatic reactions more reliable than generic error messages with text.
  • Rate limiting works better when clients learn when they may try again.

Facts

  • RFC 6585 appeared in April 2012 and has ten pages.
  • It defines the status codes 428, 429, 431 and 511.
  • 429 may contain a Retry-After header.
  • Responses with 511 must not be stored in a cache.

References

Remarks

  • Modern operating systems mostly detect captive portals through their own test addresses; since 2020 RFC 8908 has described an API through which networks announce their portal directly.

Recommendations

  • When rate limiting, send 429 with Retry-After instead of silently dropping requests.
  • Limit header sizes uniformly in proxy, web server and application so that 431 occurs predictably.
  • Build clients so that they respect Retry-After and back off exponentially.

Read the RFC at the RFC Editor

Search the Web Archive

Found a mistake or have something to add? Get in touch.