500 Internal Server Error

The server hit an unexpected condition and cannot say anything more specific about it.

Status

HTTP/1.1 500 Internal Server Error

Details

500 is the generic server failure. Something threw, and the server has no better code to describe it. The cause is on the server side, so nothing the client changes about the request is guaranteed to help.

Because it is a catch-all, a 500 is only useful with a correlation identifier. Returning an opaque error page with a request id, and logging the stack trace against that id, is the difference between a solvable incident and an unreproducible one. Never return the trace itself: it leaks paths, versions, and query structure.

Note: A 500 without a correlation id is close to undiagnosable. Return a request id and log it against the stack trace, but never return the trace itself: it leaks paths, versions, and query structure.

Common causes

How to fix it

As the client

As the server

Examples

An unhandled exception

An ordinary request that happens to hit a bug:

HTTP request

GET /api/v2/order/40213 HTTP/1.1
Host: api.example.com

The response carries a correlation id so the failure can be found in the server logs, and no stack trace:

HTTP response

HTTP/1.1 500 Internal Server Error
Content-Type: application/json; charset=utf-8

{"error":"internal_error","request_id":"01J9X2K4M7"}

Specifications

See also