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

nginx
location /example {
    return 500;
}
Apache (.htaccess)
RewriteEngine On
RewriteRule ^example$ - [R=500,L]
PHP
http_response_code(500);
echo 'Internal Server Error';
exit;
Node.js
res.writeHead(500, { 'Content-Type': 'text/plain' });
res.end('Internal Server Error');
Python (Flask)
# 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

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.