HTTPError.net

The fastest way to diagnose, understand, and fix any HTTP status code

428 Precondition Required

Fault: Client
TL;DR

The origin demands an If-Match (or similar) header to avoid the lost-update problem when several clients edit the same resource.

The server requires the request to be conditional.

What HTTP 428 Precondition Required Means

The server requires the request to be conditional.

The origin demands an If-Match (or similar) header to avoid the lost-update problem when several clients edit the same resource.

Common Causes

How to Fix It (For Visitors)

How to Fix It (For Developers/Admins)

Returning a 428 Precondition Required (Code Examples)

If you build APIs or web apps, here is how to send an HTTP 428 response and how to test for it:

Node.js (Express)

app.get('/resource', (req, res) => {
  res.status(428).json({ error: 'Precondition Required' });
});

Python (Flask)

@app.route('/resource')
def resource():
    return jsonify(error='Precondition Required'), 428

PHP

<?php
http_response_code(428);
header('Content-Type: application/json');
echo json_encode(['error' => 'Precondition Required']);

Check the status with curl

curl -I https://example.com/resource
# Look for: HTTP/1.1 428 Precondition Required

Frequently Asked Questions

What does HTTP 428 Precondition Required mean?

The origin demands an If-Match (or similar) header to avoid the lost-update problem when several clients edit the same resource. In short: The server requires the request to be conditional.

Is 428 Precondition Required a client or server error?

428 is a 4xx client-error code, so the request itself needs to change. The server is running normally and is rejecting the request as it was sent by the browser, app, or API client.

How do I fix a 428 Precondition Required error?

Fetch the resource, then send its ETag in If-Match. Always make write requests conditional. Document the required precondition headers.

Official Specification

The 428 Precondition Required status code is defined in RFC 6585 Section 3.

View the IANA HTTP Status Code Registry →