What 500 Internal Server Error means

500 Internal Server Error is the catch-all server-fault code. The server encountered an unexpected condition (uncaught exception, null pointer, database connection refused, deserialization crash) and could not complete the request. 500 says nothing about why; the actual cause is in the server logs. From the client's perspective, 500 means "this is not your fault, retry might help, file a bug if it persists".

When servers should return it: Return 500 only for genuinely unexpected server-side failures. Use 503 for known overload, 502 for upstream failures, 504 for upstream timeouts.

Common causes

  • Uncaught exception in application code
  • Database connection failure
  • Null reference / undefined access
  • Out of memory
  • Deserialization or parsing error in business logic
  • Misconfiguration (missing environment variable, bad credentials)

How to fix 500 Internal Server Error

  • Check server logs for the stack trace
  • Retry the request, may be transient
  • For consistent 500s, file a bug report with the exact request and timestamp
  • For your own services, add better error handling and convert to specific 4xx where appropriate

Example response

HTTP/2 500
content-type: application/json
{"error":"internal server error","request_id":"abc123"}

More references

For a one-page reference of all HTTP status codes, see the HTTP cheat sheet. For testing API responses, try the API Tester tool. For inspecting responses on the command line, the curl cheat sheet covers the most common flags.