HTTP 412 Precondition Failed vs 500 Internal Server Error
HTTP 412 (Precondition Failed) is a 4xx Client Error response, while 500 (Internal Server Error) is a 5xx Server Error response. 412 indicates that one or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false. In contrast, 500 means that the server encountered an unexpected condition that prevented it from fulfilling the request. A generic catch-all for server-side errors.
Description
One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
When You See It
When using conditional requests with ETags and the resource has changed.
How to Fix
Refresh the ETag/Last-Modified value and retry with updated preconditions.
Description
The server encountered an unexpected condition that prevented it from fulfilling the request. A generic catch-all for server-side errors.
When You See It
When an unhandled exception occurs, a database connection fails, or server code has a bug.
How to Fix
Check server logs for the stack trace. Common causes: unhandled exceptions, database errors, misconfigurations.
Key Differences
412 is a 4xx Client Error response, while 500 is a 5xx Server Error response.
HTTP 412: One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
HTTP 500: The server encountered an unexpected condition that prevented it from fulfilling the request. A generic catch-all for server-side errors.
You encounter 412 when when using conditional requests with ETags and the resource has changed.
You encounter 500 when when an unhandled exception occurs, a database connection fails, or server code has a bug.
When to Use Which
For 412 (Precondition Failed): Refresh the ETag/Last-Modified value and retry with updated preconditions. For 500 (Internal Server Error): Check server logs for the stack trace. Common causes: unhandled exceptions, database errors, misconfigurations.