More
More
500 Internal Server Error
Something went wrong on the server and it has no more specific code to give.
- Code
500- Reason phrase
- Internal Server Error
- Class
- 5xx Server error
- Defined in
- RFC 9110 section 15.6.1
- Cacheable by default
- No
What it means
Server error: the request may be fine, but the server failed to carry it out.
When a server should send it. When the server hit an unexpected condition and no more specific 5xx fits: an exception, a fatal error, a broken configuration. Log the details on the server and show the visitor a plain error page without stack traces.
Common causes. A bug or crash in the application, a PHP fatal error, a bad .htaccess rule, or a database error.
What to do. Visitors can only retry later. Site owners should check the server and application error logs, which name the actual failure.
How clients and crawlers treat it
Browsers and HTTP clients. Browsers show the body. Many HTTP clients retry 5xx for idempotent requests such as GET, but not for POST.
Google Search. Googlebot treats 5xx responses as a sign of trouble and temporarily slows its crawl rate. Already indexed URLs are kept at first, but are dropped if the errors continue. Source: Google Search Central, How HTTP status codes, and network and DNS errors affect Google Search.
Caching. Not cacheable by default (RFC 9110 section 15.1 does not list it). A cache stores it only when the response says so with Cache-Control or Expires.
Example response
HTTP/1.1 500 Internal Server Error Content-Type: text/plain; charset=utf-8 Internal Server Error
How to send 500
location /example {
return 500;
}
RewriteEngine On RewriteRule ^example$ - [R=500,L]
http_response_code(500); echo 'Internal Server Error'; exit;
res.writeHead(500, { 'Content-Type': 'text/plain' });
res.end('Internal Server Error');
# in a view function return 'Internal Server Error', 500
Change the paths to suit. In nginx, add_header needs always to apply to error responses.
Related codes
- 502Bad GatewayA proxy, load balancer or CDN got an invalid response from the server behind it.
- 503Service UnavailableThe server cannot handle the request right now.
- 504Gateway TimeoutA proxy or CDN waited too long for the server behind it.
All status codes · All 5xx codes
Names and numbers from the IANA HTTP Status Code Registry. Google Search behaviour as documented by Google Search Central.