500 Internal Server Error

Something went wrong on the server.

When to use it

Unhandled exceptions. Log the details, don’t leak them to the client.

Common causes and fixes

A 500 means an unhandled exception or misconfiguration on the server. Start with the logs at the time of the request: application stack traces, PHP or Python error logs, journalctl, docker logs or CloudWatch. Common causes: a null or undefined value, a failed database query or unapplied migration, a missing environment variable in production, a syntax error in .htaccess, or wrong permissions on a script.

Make 500s debuggable: return a request ID in a header and the body, log it with the stack trace, and send errors to a tracker such as Sentry. Never show stack traces to clients in production. Don’t use 500 for client mistakes; validation failures belong in 4xx, so alerting on 5xx stays meaningful. Retrying with backoff helps transient failures, but a deterministic bug fails every time.

Server error (5xx)

5xx codes are server errors: the request may be fine, but the server or something behind it failed. These are worth alerting on.

What it looks like

HTTP/1.1 500 Internal Server Error

How to send it

Node.js / Expressres.status(500).end()
Python / Flaskreturn '', 500
nginxreturn 500;

How to check it

curl -s -o /dev/null -w "%{http_code}\n" https://example.com/

Open HTTP Status Codes