devkult_
tools29converters34

500 Internal Server Error

5xx server error

The server hit an unexpected condition and couldn't complete the request.

500 is the catch-all server failure: something went wrong that the server didn't anticipate, usually an unhandled exception. The client did nothing wrong — or nothing the server could name.

The details belong in the server's logs, not in the response: a stack trace on a 500 page shows attackers your internals.

Class5xx Server Error
Retry?With backoff (idempotent requests only)
Cacheable by defaultNo — only with explicit Cache-Control
Response bodyAllowed
Defined inRFC 9110 §15.6.1 — 500 Internal Server Error
Example response
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Content-Length: 33

{"error":"Internal Server Error"}

Common causes

  • An unhandled exception or crash in application code.
  • Misconfiguration: a missing environment variable or secret, a syntax error in .htaccess.
  • Database or dependency errors the code didn't handle.
  • Running out of memory, or a function crashing on startup.

How to fix it

  1. Check the server logs first — the stack trace points at the line.
  2. Reproduce locally with the same input and environment variables.
  3. Catch expected failures and map them to specific statuses (400, 404, 503), so 500 means 'genuinely unexpected'.
  4. Show clients a generic message plus a request id, and log the details against that id.

Send a 500 from your server

Express
res.status(500).json({ error: "Internal Server Error" });
Next.js route handler
return Response.json({ error: "Internal Server Error" }, { status: 500 });
Flask
return {"error": "Internal Server Error"}, 500
Go net/http
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
nginx
return 500;

Check what a URL returns

Print just the status line from the command line, or check a whole list of URLs at once, with their response headers, in the HTTP Status Checker.

curl -sI https://example.com/your-path | head -n 1

Frequently asked questions

Is a 500 my fault as a visitor?

Usually not — the server failed. Retrying later may work; if it keeps happening, tell the site what you were doing and when.

500 vs 502 vs 503?

500: the application itself failed. 502: a proxy got a bad response from the application. 503: the server is temporarily unable to serve — overloaded or in maintenance.

Related status codes