An HTTP 500 Internal Server Error means the web server hit an unexpected problem and couldn’t complete the request. It is a generic “something broke on the server” response. The server knows the request failed, but it isn’t telling the browser why. The real reason is almost always written in a log file on the server.
This guide explains what the 500 status code means, the most common causes, and how to fix it. It covers quick checks for visitors, then step-by-step troubleshooting for site owners running Apache, Nginx, PHP-FPM, WordPress, Node.js or Python apps, and IIS.
What Does HTTP 500 Mean?
HTTP status codes are three-digit numbers that a server sends back with every response. The first digit tells you the class:
| Class | Meaning | Examples |
|---|---|---|
| 1xx | Informational | 100 Continue |
| 2xx | Success | 200 OK |
| 3xx | Redirection | 301 Moved Permanently |
| 4xx | Client error (the request was wrong) | 403 Forbidden, 404 Not Found |
| 5xx | Server error (the server failed) | 500, 502, 503, 504 |
The HTTP standard (RFC 9110) defines 500 as: the server “encountered an unexpected condition that prevented it from fulfilling the request.” It is the catch-all server error. Servers use it when no more specific 5xx code fits.
You may see it worded in different ways, depending on the site and server:
500 Internal Server ErrorHTTP Error 500orHTTP ERROR 500(Chrome’s “This page isn’t working” screen)500. That's an error.There has been a critical error on this website.(WordPress)HTTP Error 500.0 - Internal Server Error(Microsoft IIS)
500 vs 502, 503 and 504
Other 5xx codes point to a more specific problem, so it’s worth checking which one you actually got:
| Code | Name | What usually happened |
|---|---|---|
| 500 | Internal Server Error | The application or server itself crashed or hit an error (bad code, bad config, permissions, memory limit). |
| 502 | Bad Gateway | A proxy such as Nginx couldn’t get a valid response from the backend (PHP-FPM, Node.js, Gunicorn is down or crashed). |
| 503 | Service Unavailable | The server is overloaded or in maintenance mode. Usually temporary. |
| 504 | Gateway Timeout | The backend was too slow and the proxy gave up waiting. |
To see the exact status code a URL returns, use curl (see how to get the HTTP status code with curl):
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/page/curl -I https://example.com/page/
Common Causes of a 500 Error
- Errors in application code: a PHP fatal error, an uncaught exception in Python or Node.js, a syntax error after an edit or a failed deployment.
- A bad
.htaccessfile (Apache): a typo, or a directive for a module that isn’t enabled, such asRewriteEnginewithout mod_rewrite. - Redirect or rewrite loops: rewrite rules that keep sending the request back to itself.
- Wrong file permissions or ownership: the web server can’t read a script, or can’t write to a cache, upload or session directory.
- PHP limits: the script ran out of memory (
memory_limit) or ran too long (max_execution_time). - Broken plugins, themes or modules: very common on WordPress and other CMSs after an update.
- Database connection failures that the application doesn’t handle gracefully.
- A full disk, so the app can’t write sessions, cache or logs.
- Security layers such as SELinux blocking the web server from reading files or opening network connections.
Quick Fixes If You’re Visiting the Site
A 500 error is a problem on the website’s side, not with your device. There is little a visitor can fix, but these steps rule out short glitches:
- Reload the page after a minute (F5 or Ctrl+R; Cmd+R on a Mac). Many 500 errors happen during a deployment or restart and go away by themselves.
- Clear the site’s cookies and cache, or open the page in a private/incognito window. A broken session cookie can trigger errors on some sites.
- Try another browser, device or network to see if the error is only on your side.
- Check whether the site is down for everyone using the company’s status page or its social media accounts.
- Come back later or contact the site owner, and tell them the page URL and the time of the error. That helps them find the matching log entry.
If you submitted a form or a payment, don’t resend it straight away. Check your email or account first, because the action may have gone through before the error.
How to Fix a 500 Error on Your Own Server
Step 1: Read the error log
This is the single most useful step. The 500 page is deliberately vague, but the server writes the real error to its log. Reproduce the error, then look at the most recent lines:
| Server | Default error log |
|---|---|
| Apache (Ubuntu, Debian) | /var/log/apache2/error.log |
| Apache (RHEL, Rocky, AlmaLinux, Fedora) | /var/log/httpd/error_log |
| Nginx | /var/log/nginx/error.log |
| PHP-FPM (Ubuntu, Debian) | /var/log/php8.3-fpm.log (version-specific) |
| WordPress (with debug log on) | wp-content/debug.log |
| systemd services (Node.js, Gunicorn, etc.) | journalctl -u <service> |
| IIS | %SystemDrive%\inetpub\logs\LogFiles |
Your virtual host may define its own log file with an ErrorLog (Apache) or error_log (Nginx) directive, so check the site’s config if the default log is empty. Watch the log live while you reload the failing page (more on the tail command):
sudo tail -f /var/log/apache2/error.logsudo tail -f /var/log/nginx/error.logsudo journalctl -u myapp -f
With Nginx and PHP-FPM, PHP errors usually appear in the Nginx error log, prefixed with FastCGI sent in stderr: "PHP message: .... The rest of this guide covers the messages you’re most likely to find.
Step 2: Test the server configuration
If the error started right after a config change, check the syntax before you do anything else:
sudo apachectl configtestsudo nginx -tsudo php-fpm8.3 -t
Fix any error these report, then reload the service (for example sudo systemctl reload nginx).
Step 3: Check the .htaccess file (Apache)
Apache reads .htaccess on every request, so a single bad line breaks the whole directory with a 500 error. A typical log entry looks like this:
.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
This one means mod_rewrite isn’t enabled. On Ubuntu and Debian, enable it and restart Apache (see how to enable mod_rewrite):
sudo a2enmod rewritesudo systemctl restart apache2
If you’re not sure which line is the problem, rename the file and test again. If the site loads, the cause is in .htaccess. Restore it and remove rules one at a time until you find the bad one:
mv .htaccess .htaccess.bak
Step 4: Look for rewrite and redirect loops
Rewrite rules that point back to themselves make the server give up with a 500. In the logs you’ll see:
# Apache
Request exceeded the limit of 10 internal redirects due to probable configuration error.
# Nginx
rewrite or internal redirection cycle while internally redirecting to "/index.php"
In Nginx this often comes from a try_files line whose final fallback (for example /index.php) doesn’t exist or isn’t passed to PHP. Check that the file exists in the root directory and that a location ~ \.php$ block handles it.
Step 5: Fix file permissions and ownership
The web server user (www-data on Ubuntu/Debian, apache or nginx on RHEL-based systems) must be able to read your files and write to cache, upload and session folders. A safe default for most PHP sites is 755 for directories and 644 for files:
sudo chown -R www-data:www-data /var/www/example.comsudo find /var/www/example.com -type d -exec chmod 755 {} \;sudo find /var/www/example.com -type f -exec chmod 644 {} \;
Don’t “fix” errors with chmod 777. It is a security risk, and on hosts that run PHP through suEXEC or suPHP, files writable by everyone are refused and cause a 500 error themselves. See how to chmod files and directories recursively for more examples.
On RHEL, Rocky Linux, AlmaLinux and Fedora, SELinux can also block access even when permissions look correct. Check for recent denials:
sudo ausearch -m avc -ts recent
If you see denials for httpd, see how to configure SELinux for an Apache directory.
Step 6: Find PHP errors and limits
On production servers PHP hides errors from visitors, and a fatal error turns into a blank 500 page. Look for lines like these in the log:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)
PHP Fatal error: Maximum execution time of 30 seconds exceeded
PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect()
PHP Parse error: syntax error, unexpected token "}"
- Memory exhausted: raise
memory_limitinphp.ini(for examplememory_limit = 256M), or find the code that uses so much memory. - Maximum execution time exceeded: raise
max_execution_time, or move long jobs to a background task or cron. - Call to undefined function: a PHP extension is missing (for example
php8.3-mysql), or the code uses a function removed in your PHP version. This is common after a PHP upgrade. - Parse/syntax error: a typo in the file named in the message. Check it with
php -l file.php.
Find which php.ini is in use with php --ini (PHP-FPM has its own file, for example /etc/php/8.3/fpm/php.ini), then restart PHP-FPM after changes:
sudo systemctl restart php8.3-fpm
To see errors on a development server, turn on display_errors. Never leave it on in production. Our guide on how to enable PHP errors shows the settings. If the log shows server reached pm.max_children setting, PHP-FPM is out of workers, which usually causes slow pages and 502/504 errors rather than 500. See how to fix the pm.max_children error.
Step 7: Check disk space and the database
A full disk stops applications from writing sessions, cache files and logs, and a stopped database makes most CMSs fail. Check both quickly:
df -hsudo systemctl status mysql
On some systems the database service is called mariadb or mysqld instead.
Step 8: Roll back recent changes
Most 500 errors start right after something changed: a deployment, a plugin or theme update, a PHP upgrade or a config edit. If the logs point to new code, roll back to the last working release, then fix the problem on a test copy rather than on the live site.
Fixing a 500 Error in WordPress
Since WordPress 5.2, most PHP fatal errors show the message “There has been a critical error on this website.” WordPress also emails the site administrator a link to recovery mode, where you can log in and disable the plugin or theme that crashed. If you don’t get the email, follow these steps:
- Turn on the debug log. Add these lines to
wp-config.php, above the line/* That's all, stop editing! */:define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false );Reload the page, then read
wp-content/debug.log. The fatal error usually names the plugin or theme folder. SetWP_DEBUGback tofalsewhen you’re done. - Disable all plugins by renaming the plugins folder. If the site comes back, rename it back and disable plugins one at a time to find the faulty one:
mv wp-content/plugins wp-content/plugins.off - Switch to a default theme by renaming your active theme’s folder in
wp-content/themes/. WordPress then falls back to a default theme (one of the “Twenty” themes), so make sure one is installed. - Regenerate
.htaccesson Apache. Rename the file, then go to Settings → Permalinks and click Save Changes. WordPress writes a fresh file with its standard rewrite rules. - Raise the memory limit if the log shows memory exhausted: add
define( 'WP_MEMORY_LIMIT', '256M' );towp-config.php. It can’t go above the server’s PHPmemory_limit.
Node.js, Python and Other Apps Behind a Proxy
When Nginx or Apache acts as a reverse proxy, a 500 normally comes from the application itself: an uncaught exception or a crashed request handler. (If the app is down completely, you get a 502 instead.) Read the app’s own log or its systemd journal:
sudo journalctl -u myapp --since "10 minutes ago"pm2 logs
Look for a stack trace at the time of the error. Common causes are missing environment variables after a deploy, an unreachable database or API, and code that doesn’t handle empty or unexpected input. Frameworks such as Django, Flask and Laravel show a detailed error page in debug mode. Turn it on only in development (for Laravel, see how to enable debug mode).
IIS: HTTP Error 500.x Substatus Codes
Microsoft IIS adds a substatus code after the 500, which narrows down the cause:
| Code | Meaning |
|---|---|
| 500.0 | Module or ISAPI error. Often a PHP or ASP.NET error or a handler problem. |
| 500.19 | Configuration data is invalid. Usually a bad web.config, or a section for a module that isn’t installed (such as URL Rewrite). |
| 500.21 | Module not recognized. A handler references a module that isn’t installed. |
| 500.100 | Internal ASP error in a classic ASP page. |
On the server itself, IIS shows a detailed error page for local requests by default, so open the site from the server’s own browser to see the full message. For more detail, enable Failed Request Tracing for the site in IIS Manager.
Does a 500 Error Hurt SEO?
A short outage won’t hurt your rankings. If Googlebot gets many 5xx responses, it slows down crawling your site for a while. If a URL keeps returning a server error for a long time, Google can eventually drop it from the index. Fix persistent 500 errors quickly and check the Pages report in Google Search Console for “Server error (5xx)” URLs.
For planned maintenance, return 503 Service Unavailable with a Retry-After header instead of 500. It tells browsers and search engines the outage is temporary.
How to Prevent 500 Errors
- Test updates and deployments on a staging copy before production.
- Run
nginx -torapachectl configtestbefore every reload. - Keep PHP, plugins and dependencies updated, and check compatibility before major PHP upgrades.
- Monitor disk space, memory and your error logs, and set up an uptime check that alerts you on 5xx responses.
- Keep backups and a quick rollback path for code and configuration.
- Show visitors a friendly custom 500 page, while logging the full error on the server.
Related HTTP Error Guides
For the full list of codes and what they mean, see our HTTP status codes list. Guides for other common errors:
- HTTP 400 Bad Request
- HTTP 401 Unauthorized
- HTTP 403 Forbidden
- HTTP 404 Not Found
- HTTP 429 Too Many Requests
- HTTP 502 Bad Gateway
- HTTP 503 Service Unavailable
- HTTP 504 Gateway Timeout
Frequently Asked Questions
What does HTTP error 500 mean?
It means the server ran into an unexpected problem and couldn’t complete your request. The problem is on the website’s server, not on your device or connection.
Is a 500 error my fault?
Almost never. It is a server-side error. Reloading the page or trying later is usually all a visitor can do. If it persists, let the site owner know.
How do I find the cause of a 500 error?
Check the web server’s error log right after the error happens: /var/log/apache2/error.log or /var/log/nginx/error.log on most Linux servers. The log records the exact message, such as a PHP fatal error or a bad .htaccess directive.
What is the difference between 500 and 502 errors?
A 500 means the server or the application itself failed. A 502 Bad Gateway means a proxy (such as Nginx) couldn’t get a valid response from the backend, often because PHP-FPM or the app is down.
Can .htaccess cause a 500 Internal Server Error?
Yes. On Apache, a syntax error or a directive from a module that isn’t enabled in .htaccess causes a 500 for every page in that directory. Rename the file to test, then fix the bad line.
How do I fix a 500 error in WordPress?
Enable WP_DEBUG_LOG and read wp-content/debug.log, then disable plugins by renaming the plugins folder, switch to a default theme and regenerate .htaccess from Settings → Permalinks.
Conclusion
An HTTP 500 Internal Server Error is the server’s way of saying “something went wrong, and I won’t say what to the browser.” For visitors, a reload or a later retry is usually all there is to do. For site owners, the fix nearly always starts in the error log, which names the real problem: a PHP fatal error, a bad .htaccess line, a rewrite loop, wrong permissions or a resource limit. Check the log first, test your configuration, roll back recent changes, and you’ll resolve most 500 errors in minutes.
How did it make you feel?
