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.
- Source: RFC6585 Section 3
428 CODE REFERENCES
Symfony HTTP Status Constant
Apache HttpComponents Core
428 status code example
Here’s an example request and response for a 428 status code:
GET /example HTTP/1.1
HTTP/1.1 428 Precondition Required
Date: Mon, 07 Mar 2023 16:30:00 GMT
Content-Type: text/html; charset=UTF-8
<title>428 Precondition Required</title>
<h1>428 Precondition Required</h1>
<p>The origin server requires the request to be conditional.</p>
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
Preferheader. Make sure the
Preferheader value is set to
- Check if the server is correctly interpreting the
Preferheader. The server should be set to return a 428 status code if the
handlingdirective is not set to
- 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.
- Learn about web development
- Learn about SEO
- Web development services from WebFX
- SEO services from WebFX
- MDN Web Docs