500 Internal Server Error
The application code threw and nothing caught it: an unhandled exception, a null dereference, a failed assertion. Of the common 5xx family, 500 is the one that is unambiguously your bug — the stack trace is in your application logs, at the timestamp of the request.
What usually causes it
- Unhandled exceptions on edge-case inputs
- Failed dependencies without graceful handling (DB down → exception → 500)
- Bad deployments (missing env vars, broken migrations)
How to debug and fix it
- Get the request ID / timestamp and go straight to app logs or your error tracker (Sentry-class tooling exists exactly for this).
- If 500s started at a deploy, roll back first and diagnose second.
- Never leak stack traces in the response body in production — log them, return a reference ID.
- Convert 'expected' failures (bad input, missing resource) into their correct 4xx codes so real 500s stay meaningful.
Easily confused with
Debugging an API? Build and inspect requests, check response headers, or read the full status-code debugging guide.