5xx Server error · RFC 9110 §15.6.1

500 Internal Server Error

The server hit an unexpected condition it could not handle.

What 500 means

The generic server failure: an unhandled exception, a crashed worker, a database error that bubbled up, a misconfiguration. The response tells the client nothing useful by design; the details are in the server log.

Find the request id or timestamp in the access log, then the matching stack trace in the application log. Sharing that trace with a teammate is what tools like Log Share are for.

Common causes

  • Unhandled exception in application code.
  • Database connection failure or timeout surfaced as an error.
  • Missing environment variable, bad permissions on a file the app needs.
  • Web server misconfiguration (.htaccess syntax, PHP fatal error).

How to fix it

  • Read the application log at the time of the request; the 500 page itself is not the evidence.
  • Add a request id header and log it on both sides to correlate.
  • Return 5xx for real failures but catch expected errors and return 4xx.

What it looks like

A typical response:

HTTP/1.1 500 Internal Server Error
Content-Type: text/html
X-Request-Id: 8f3a-4c2d

The same event in an nginx access log (the status is the number after the request line):

203.0.113.7 - - [10/Sep/2026:10:12:01 +0000] "GET /checkout HTTP/1.1" 500 153 "-" "Mozilla/5.0"

Check it with curl

-i prints the status line and headers, and -w '%{http_code}' prints only the number, which is handy in scripts and health checks. Replace the URL with yours:

curl -sS -o /dev/null -w '%{http_code} %{time_total}s\n' https://example.com/api/orders

Compare what curl sees with what the browser sees. A different status from the same URL usually means a cache, a CDN edge or a cookie is in the way.

Investigating a run of 500s? Paste the log excerpt into Log Share to get line numbers, highlighting and an expiring link for whoever is on call with you.

  • 502Bad Gateway: A proxy or load balancer got an invalid response from the upstream server.
  • 503Service Unavailable: The server is temporarily unable to handle the request.
  • 504Gateway Timeout: A proxy or load balancer gave up waiting for the upstream server.

FAQ

Is a 500 my fault as a user?

No. It is a server-side failure. Retrying later may work; reporting the time and the request id helps the operators find it.

How do I see the real error behind a 500?

In the server logs (application log, error log). Never expose stack traces to users in production; log them with a request id instead.