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
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.
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.
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.
Related reading
- 501 Not Implemented: how to fix it: Fix 501 Not Implemented: unsupported HTTP methods, servers and proxies that do not support PATCH or WebDAV, and how it differs from 405 and 500.
- 408 Request Timeout: causes and how to fix it: Understand 408 Request Timeout: slow client uploads, idle keep-alive connections and proxy settings, and how it differs from a 504 Gateway Timeout.
- ERR_CONTENT_DECODING_FAILED: how to fix it: Fix ERR_CONTENT_DECODING_FAILED: wrong Content-Encoding headers, double gzip compression, broken Brotli, PHP output buffering and proxies, with tests.
- 403 Forbidden: what it means and how to fix it: Fix 403 Forbidden errors: file permissions, missing index files, WAF and bot rules, IP allowlists, expired signed URLs and missing API scopes, step by step.
- 500 Internal Server Error: how to find the cause: A 500 error means your code failed. Find the exception behind it fast with logs, traces and error tracking, and learn how to prevent repeats.
- 503 Service Unavailable: causes and fixes: Why servers return 503 Service Unavailable, from overload and maintenance to no healthy backends, how to diagnose each cause and how to recover and prevent it.
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.