What Is a 428 Status Code?

The origin server requires the request to be conditional.

Its typical use is to avoid the “lost update” problem, where a client GETs a resource’s state, modifies it, and PUTs it back to the server, when meanwhile a third party has modified the state on the server, leading to a conflict. By requiring requests to be conditional, the server can assure that clients are working with the correct copies.

Responses using this status code SHOULD explain how to resubmit the request successfully. For example:

HTTP/1.1 428 Precondition Required
Content-Type: text/html

<html>
  <head>
    <title>Precondition Required</title>
  </head>
  <body>
    <h1>Precondition Required</h1>
    <p>This request is required to be conditional; try using "If-Match".</p>
  </body>
</html>

Responses with the 428 status code MUST NOT be stored by a cache.


428 CODE REFERENCES

Symfony HTTP Status Constant Response::HTTP_PRECONDITION_REQUIRED

.NET HttpStatusCode.PreconditionRequired

Rust http::StatusCode::PRECONDITION_REQUIRED

Rails :precondition_required

Go http.StatusPreconditionRequired

Symfony Response::HTTP_PRECONDITION_REQUIRED

Python 3.5+ http.HTTPStatus.PRECONDITION_REQUIRED

Apache HttpComponents Core org.apache.hc.core5.http.HttpStatus.SC_PRECONDITION_REQUIRED

Angular @angular/common/http/HttpStatusCode.PreconditionRequired

428 status code example

Here’s an example request and response for a 428 status code:

Request

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

Response

HTTP/1.1 428 Precondition Required
Date: Mon, 07 Mar 2023 16:30:00 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 114

<!DOCTYPE html>
<html>
<head>
<title>428 Precondition Required</title>
</head>
<body>
<h1>428 Precondition Required</h1>
<p>The origin server requires the request to be conditional.</p>
</body>
</html>

What causes a 428 status code?

A 428 Precondition Required status code indicates that the server requires the client to send a conditional request based on the server’s specified preconditions. In other words, the server needs certain conditions to be met before it can process the client’s request. The client must include one or more preconditions in the request headers.

Some common reasons for receiving a 428 status code include:

  • The server requires a specific version of the resource
  • The server requires the client to authenticate itself before processing the request
  • The server requires a specific MIME type for the resource
  • The server requires certain headers to be present in the request before it can be processed

If you receive a 428 status code, you should check the request headers to ensure that the required preconditions are included. You may need to modify the request headers or include additional information to meet the server’s requirements.

How to troubleshoot a 428 status code

You can troubleshoot a 428 status code by following these steps:

  • Check if the user agent is correctly sending the required Prefer header. Make sure the Prefer header value is set to handling=lenient.
  • Check if the server is correctly interpreting the Prefer header. The server should be set to return a 428 status code if the handling directive is not set to lenient.
  • Check if there are any conflicting headers or directives. Conflicting headers or directives can cause the server to respond with a 428 status code.
  • Check if the client has appropriate access rights to the resource. The client may not have sufficient permissions to access the resource, which can result in a 428 status code.
  • Check if the server has the necessary resources to fulfill the request. The server may not have the required resources to fulfill the request, leading to a 428 status code.

If none of the above steps work, try contacting the website administrator for further assistance in resolving the issue.

Additional resources


Return to List of HTTP Status Codes

TO TOP