500 Internal Server Error
HTTP response status code 500 Internal Server Error is a catch-all server error indicating the server encountered an unexpected condition preventing the request from being fulfilled.
Usage
The 500 Internal Server Error status code signals a generic failure on the server side. Due to the broad nature of this error, the specific cause depends on the environment. The web server is experiencing problems and the server administrator needs to take action to resolve the issue.
The error is often attributed to a permissions
problem on one or more files, a script timeout,
or corruption in the .htaccess file. The only
certainty is the HTTP request was not fulfilled.
SEO impact
Googlebot treats
5xx errors as a
signal to temporarily reduce the crawl rate
across the site. Previously indexed URLs are
preserved initially, but extended downtime
causes Google to drop them from the index. Any
content returned with a 500 response is
ignored. Google treats 500, 502, and
503 identically in this regard. A
5xx error on the
robots.txt
file is far more severe, even when every other
page on the site returns 200. Google halts
crawling for up to 12 hours, then falls back to
a cached copy for up to 30 days. If the error
persists, Google fully deindexes the site.
Bingbot also treats
5xx responses as
crawl failures. Persistent
5xx errors prevent
indexing in Bing.
Example
The client requests a resource and the server responds with a 500 Internal Server Error status code, indicating the request will not be satisfied.
Request
GET /news.html HTTP/1.1
Host: www.example.re
Response
HTTP/1.1 500 Internal Server Error
Content-Type: text/html; charset=UTF-8
Content-Length: 139
<html>
<head>
<title>Request Failed</title>
</head>
<body>
<p>The request failed due to a server error.</p>
</body>
</html>
How to fix
Start with the error log. In nginx, check
/var/log/nginx/error.log. In Apache, check
/var/log/apache2/error.log or
/var/log/httpd/error_log. The log entry almost
always names the failing file and line number.
Common root causes and their fixes:
- File permissions. The web server process needs
read access to application files and write access
to upload or cache directories. On Linux, set
directories to
755and files to644. Confirm the owner matches the web server user (www-dataon Debian/Ubuntu,nginxorapacheon RHEL/CentOS). - Corrupted
.htaccess. On Apache, rename.htaccesstemporarily to confirm. A single invalid directive or a reference to an unloaded module triggers a 500 for every request in the directory tree. - PHP fatal errors. Syntax errors, undefined
function calls, and exceeded
memory_limitall produce a 500. Setdisplay_errors = Offandlog_errors = Oninphp.ini, then read/var/log/php/errors.log. Raisememory_limitwhen the log shows "Allowed memory size exhausted." - PHP-FPM crashes. When nginx proxies to
PHP-FPM and the pool dies, the error log shows
"upstream prematurely closed connection." Check
the PHP-FPM pool log for segfaults or
out-of-memory kills. Increase
pm.max_childrenif the pool runs out of workers. - Database connectivity. Wrong credentials,
unreachable host, or connection pool exhaustion
all surface as a 500. Test connectivity directly
from the server (
mysql -u user -p -h hostorpsql -U user -h host) to isolate the database from the application. - Disk full. A server with no free disk space
fails to write temporary files, sessions, or
logs. Run
df -hand clear old logs, cache files, or core dumps.
After identifying the cause, deploy the fix and monitor the error log for recurrence. Set up log alerting to catch 500 spikes before users report them.
Code references
.NET
HttpStatusCode.InternalServerError
Rust
http::StatusCode::INTERNAL_SERVER_ERROR
Rails
:internal_server_error
Go
http.StatusInternalServerError
Symfony
Response::HTTP_INTERNAL_SERVER_ERROR
Python3.5+
http.HTTPStatus.INTERNAL_SERVER_ERROR
Java
java.net.HttpURLConnection.HTTP_INTERNAL_ERROR
Apache HttpComponents Core
org.apache.hc.core5.http.HttpStatus.SC_SERVER_ERROR
org.apache.hc.core5.http.HttpStatus.SC_INTERNAL_SERVER_ERROR
Angular
@angular/common/http/HttpStatusCode.InternalServerError
Takeaway
The 500 Internal Server Error status code is a catch-all server error indicating the HTTP request was not fulfilled due to an unexpected server-side condition.
See also
- RFC 9110: HTTP Semantics
- Google: HTTP status codes and network errors
- 501 Not Implemented
- 502 Bad Gateway
- 503 Service Unavailable
- 504 Gateway Timeout
- HTTP status codes