DevToolsmith

HTTP 500 Internal Server Error

HTTP 500 Internal Server Error means the server hit an unexpected error and couldn’t complete the request. The server failed to fulfil a valid request. The problem is on the server side.

Class
5xx Server error
Standard
RFC 9110
Cacheable by default
No
Safe to retry
Sometimes
Go constant
http.StatusInternalServerError

What HTTP 500 means

The generic server-side failure: an unhandled exception, a bug, a crashed database query. The problem isn’t in the request itself, though a particular input may have triggered the bug. The details are in the server logs, not in the response, which shouldn’t expose stack traces in production.

How to fix a 500 error

  • Check the application log first: the stack trace shows the failing line.
  • On Apache with PHP, a syntax error in .htaccess causes 500 for every request.
  • Missing environment variables or database credentials after a deploy are a frequent cause.
  • If it only happens sometimes, check memory limits and connection pool exhaustion.

Retrying

Sometimes. Retry idempotent requests (GET, PUT, DELETE) once or twice; don’t blindly retry a POST that may have partly succeeded.

Example response

HTTP/1.1 500 Internal Server Error
Date: Wed, 21 Oct 2026 10:30:00 GMT
Content-Type: application/json

How to return 500

Node.js (Express)
res.status(500).json({ error: 'Internal Server Error' });
Python (FastAPI)
from fastapi import HTTPException

raise HTTPException(status_code=500, detail="Internal Server Error")
Go (net/http)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
nginx
location /private/ {
    return 500;
}

Related status codes

Other 5xx status codes

501 Not Implemented · 502 Bad Gateway · 503 Service Unavailable · 504 Gateway Timeout · 505 HTTP Version Not Supported · 507 Insufficient Storage · 508 Loop Detected · 511 Network Authentication Required · 520 Web Server Returned an Unknown Error · 521 Web Server Is Down · 522 Connection Timed Out · 523 Origin Is Unreachable · 524 A Timeout Occurred · 525 SSL Handshake Failed · 526 Invalid SSL Certificate

See the full list of HTTP status codes.

Sources

Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.

Frequently asked questions

What does HTTP 500 Internal Server Error mean?

HTTP 500 Internal Server Error means the server hit an unexpected error and couldn’t complete the request. The generic server-side failure: an unhandled exception, a bug, a crashed database query. The problem isn’t in the request itself, though a particular input may have triggered the bug. The details are in the server logs, not in the response, which shouldn’t expose stack traces in production.

How do I fix HTTP 500?

Check the application log first: the stack trace shows the failing line. On Apache with PHP, a syntax error in .htaccess causes 500 for every request. Missing environment variables or database credentials after a deploy are a frequent cause. If it only happens sometimes, check memory limits and connection pool exhaustion.