breakitdown

500 Internal Server Error

Answer

500 Internal Server Error means the server hit an unexpected condition, usually an unhandled exception, and has no more specific code to give. The cause is in the server's logs, not in the response.

500
Internal Server Error RFC 9110 §15.6.1

Something went wrong on the server, and it has no more specific code to report.

Almost always an unhandled exception or crash in application code; the detail is in the server's error log, not the response. Clients cannot fix it by changing the request, though retrying idempotent requests can help with transient faults. Do not return stack traces in a 500 body in production.

Explained

If the server is yours, the response body rarely helps: production frameworks hide details on purpose. The stack trace is in the application log, the error tracker (Sentry and the like), or the web server's error log.

500 comes from the server that ran the code. If a proxy sits in front, a crash in the app usually reaches the client as a 500 only if the app managed to send a response. If the app process died or never answered, the proxy reports 502 or 504 instead.

With PHP-FPM or Apache, a 500 with an empty body often means a fatal error before output started, or a syntax error in .htaccess. Check the web server error log first in those setups.

How to debug it

  1. Find the request in the application log by time, path or request ID, and read the exception.
  2. Reproduce with the same input; 500s triggered by specific data (a null field, an unexpected encoding) are common.
  3. Check what changed recently: deploys, config, environment variables, database migrations.
  4. Check dependencies the code calls: database connection limits, a downstream API returning errors, a full disk.
  5. If there is no log entry at all, the failure happened before your code ran: check the web server or runtime log.

Gotchas

Related explainers

← All HTTP status codes