500Internal Server Error
The server hit something it did not expect and could not finish the request.
How you get a 500
The request reaches the app and the code throws an error nobody handled. The framework catches it at the last moment and the app sends 500. The app is running; it just failed on this request.
Who sends itApp · Proxy
- Browser
- CDN
- Proxy
- App
- DB
Typically the application, when its code throws an error nobody handled. A proxy sends it occasionally for faults in its own configuration, such as a rewrite loop.
In short
What a 500 Internal Server Error means
A 500 Internal Server Error is the catch-all: the server tried to handle the request and something went wrong that no more specific code describes. In nearly every case the application sends it, because its code raised an error that nothing caught: a bug, a missing configuration value, a database error it did not expect, a record with data the code cannot handle. Unlike 502 or 504, the application was running, received the request and replied by itself, so the real explanation is in its own logs, usually as a stack trace next to a request ID. The response body rarely helps, since servers deliberately hide details from visitors. Whether a retry helps depends on the cause. A bug triggered by particular data fails every time; a brief database hiccup may not.
Common causes of a 500
1A bug: the code throws on input or data it did not expect.
How to check: Search the app's log for the request ID or the time. The stack trace names the line.
grep -A 20 '<request-id>' /var/log/app/error.log2A deploy went out with a missing environment variable, bad config or a failed migration.
How to check: The 500s start at the moment of the deploy and affect every request to some pages.
3The database returned an error the code does not handle: a missing column, a constraint, a lost connection.
How to check: The app's stack trace ends in the database driver. The database log has the matching error.
4Only some records trigger it, such as one customer's account with unusual data.
How to check: Compare a failing request with a working one. Look for empty or oversized fields.
5The proxy's own configuration loops.
How to check: nginx reports it in its error log, and the app has no entry.
rewrite or internal redirection cycle
Retry or not?
Safe to retry with backoff · Idempotent, a few times
Headers that matter
- X-Request-Id
- A common convention. Quote it when you search the app's logs or report the error.
- Server
- Confirms who wrote the response. A 500 page in the proxy's style means the proxy failed, not the app.
- Content-Type
- APIs often describe the error as application/problem+json. Web pages show a generic error page instead.
In the real world
RFC vs real deployments
RFC 9110 defines 500 as an unexpected condition that prevented the server from fulfilling the request. Because it is the default when code fails, it also gets used where a more precise code exists: frameworks answer 500 for bad input that should be a 400, or for an overloaded dependency that would be better reported as 503. A healthy service treats every 500 as a bug to look at.
Seen in a real outage
A burst of 500s right after a change is the classic sign of a bad rollout. In December 2025 a quarter of Cloudflare's edge traffic returned 500 after two changes went out the same day, and only on the older version of its proxy.
Your turn
Which code is it?
One customer gets a 500 every time they open their invoices page. Everyone else is fine. The response comes from the app in 40 ms and the app log shows a stack trace. What does this tell you?
Often confused with
500 questions
- Who sends a 500 Internal Server Error?
- Typically the application, when its code raises an error that nothing handled. Occasionally a proxy sends it for faults in its own configuration.
- How do I fix a 500 error?
- Find the request in the application's error log. It normally contains a stack trace that names the failing line. The response shown to visitors hides this on purpose.
- Is a 500 error my fault as a visitor?
- No. A 500 means the server failed. Reloading once is reasonable. If it keeps happening, only the site's owner can fix it.
Sources: RFC 9110: 500 Internal Server Error (section 15.6.1) ↗ · Report a problem
Diagrams are our own simulations. All wording is original and paraphrases the linked sources.
Practise this in the DNS / HTTP track
Two-minute animated lessons, then boss fights from real outages. Free, no account needed.