Skip to content

Troubleshooting guide

422 Unprocessable Entity: how to fix it

The server understood the request but the data failed validation: a missing field, a wrong format, or a business rule. The response body usually lists exactly which field.

3 min read10 sectionsUpdated

On this page

Key points

  • Syntax was fine; content was not.
  • APIs use 422 for validation errors.
  • Rails and Laravel return 422 for invalid forms and some CSRF failures.
  • Read the response body: it names the field.

What it means

422 (renamed "Unprocessable Content" in RFC 9110) means the request was well-formed JSON or form data, but the server could not act on it: an email that is not an email, an end date before a start date, a duplicate username. Unlike 400, the syntax is valid.

Common causes

  • Missing or invalid fields.
  • Values outside allowed ranges or duplicate unique values.
  • Expired or missing CSRF tokens (Rails, some frameworks).
  • Sending a field name the API does not expect.

Fixes if you are visiting the site

  1. Check the form for highlighted fields and try again.
  2. Reload the page if a form sat open for a long time (expired token).

Fixes if it is your site

Return clear field-level errors in the body and show them next to the inputs. Log 422s with the failing fields: a sudden rise after a deploy usually means the front end and API disagree on a field.

bash
curl -si -X POST https://api.example.com/users -H "Content-Type: application/json" -d '{"email":"not-an-email"}'

Reading the status code like an engineer

An HTTP status code means the connection worked and a server answered, so the network is fine and the question is which server answered and why. Look at the response headers: Server, Via and CDN-specific headers (cf-ray, x-cache) show whether a CDN, a proxy or your application produced it, and the body format usually confirms it. Then reproduce the exact request with curl, including method, headers and body, and compare it with a request that works. Monitoring should alert on unexpected codes for important URLs, and on rates of 4xx and 5xx rising after a deploy, rather than on every single error.

How site owners catch this before visitors do

Most visitors who hit 422 Unprocessable Entity leave without telling you. An uptime check every minute, with a keyword assertion on the page and an SSL check on every run, turns this from a support ticket into an alert. Keep the history: errors that come and go (one region, one server behind a load balancer, one in twenty requests) only make sense on a timeline. Put the result on a status page so people stop guessing. You can test any address now with the free website down checker.

Frequently asked questions

422 or 400?

400 for malformed requests (bad JSON); 422 for valid syntax with invalid content.

Why does Rails return 422 on login?

Often an invalid CSRF token or failed validation; check the logs.

Should monitoring alert on 422?

Not per request, but a spike after a deploy is worth an alert.

Watch your own site and services with VitalRix

Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.