500 Internal Server Error
Generic server error when no specific error code is appropriate.
The server encountered an unexpected condition that prevented it from fulfilling the request.
What HTTP 500 Internal Server Error Means
The server encountered an unexpected condition that prevented it from fulfilling the request.
Generic server error when no specific error code is appropriate.
Common Causes
- Application crash
- Uncaught exception
- Database connection error
- Code error
- Server misconfiguration
How to Fix It (For Visitors)
- Refresh the page
- Try again later
- Contact website administrator
How to Fix It (For Developers/Admins)
- Check error logs
- Debug application code
- Verify database connectivity
- Check file permissions
- Review recent code changes
- Check PHP/Python/Node.js errors
Where to Find the Real Error
A 500 is a generic wrapper: the actual cause is almost always written to a log. Check, in this order:
- Your application log or framework debug log (e.g.
wp-content/debug.logfor WordPress) - Web server error log:
/var/log/nginx/error.log, or/var/log/apache2/error.log(Debian/Ubuntu) //var/log/httpd/error_log(RHEL) - PHP-FPM or application server logs (
journalctl -u php8.2-fpm,pm2 logs, container logs)
sudo tail -n 50 /var/log/nginx/error.log
sudo tail -n 50 /var/log/apache2/error.log
Most Common Causes
- An unhandled exception or PHP fatal error (with error display turned off, the visitor only sees 500)
- A syntax error or unsupported directive in
.htaccess- Apache answers 500 for the whole directory - Wrong permissions or a missing interpreter line on CGI scripts
- Exhausted memory or a full disk
- A failed deploy: missing dependencies, environment variables, or database migrations
500 vs 502 vs 503: 500 means the application itself failed; 502 means a proxy got a bad answer from the application; 503 means the service is temporarily unavailable or overloaded.
Returning a 500 Internal Server Error (Code Examples)
If you build APIs or web apps, here is how to send an HTTP 500 response and how to test for it:
Node.js (Express)
app.get('/resource', (req, res) => {
res.status(500).json({ error: 'Internal Server Error' });
});
Python (Flask)
@app.route('/resource')
def resource():
return jsonify(error='Internal Server Error'), 500
PHP
<?php
http_response_code(500);
header('Content-Type: application/json');
echo json_encode(['error' => 'Internal Server Error']);
Check the status with curl
curl -I https://example.com/resource
# Look for: HTTP/1.1 500 Internal Server Error
Frequently Asked Questions
What does HTTP 500 Internal Server Error mean?
Generic server error when no specific error code is appropriate. In short: The server encountered an unexpected condition that prevented it from fulfilling the request.
Is a 500 Internal Server Error error my fault or the website's?
500 is a 5xx server-error code, so the problem is on the server side, not your browser or device. As a visitor you can usually only retry; if you run the site, investigate the server.
How do I fix a 500 Internal Server Error error?
Check error logs. Debug application code. Verify database connectivity.
Official Specification
The 500 Internal Server Error status code is defined in RFC 9110 Section 15.6.1.