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 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 thePrefer
header value is set tohandling=lenient
. - Check if the server is correctly interpreting the
Prefer
header. The server should be set to return a 428 status code if thehandling
directive is not set tolenient
. - 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
- Learn about web development
- Learn about SEO
- Web development services from WebFX
- SEO services from WebFX
- MDN Web Docs
- W3Schools
Marketing Tips for Niche Industries
- Tourism & Hospitality Statistics
- Treat More Patients with Healthcare Marketing Services
- Urgent Care Marketing Ideas: 5 High-ROI Tactics
- WebFX: Your Education Digital Marketing Agency
- Why Auto Part Retailers Need Digital Marketing
- Why Digital Marketing is Essential for Auctioneers
- Your Guide to Digital Marketing for Exercise Equipment Companies
- Your Guide to Digital Marketing for Industrial Repair Companies
- Vision Care Industry Statistics
- 6 Best Heavy Equipment Marketing Agencies