A 500 Internal Server Error is the web server's way of saying something went wrong and it has no more specific code for it. The message is deliberately vague, but the server almost always wrote down the real reason in a log. This guide shows you how to find that log line, translate it, and fix the usual causes on Apache, nginx, PHP, WordPress and IIS.
Visitors cannot fix a 500 because it is generated by the server; as the owner, you can usually find the cause in minutes once you stop guessing and read the log. The status is defined in RFC 9110, and the HTTP 500 reference gives the short definition.
Why 500 is a catch-all
HTTP has many specific error codes, but when application code throws an uncaught exception, a config file contains an invalid directive, or a script cannot run, the server has nothing precise to report. It falls back to 500. So the useful question is never "what is a 500?" but "what did the server log at the moment of the request?"
Get a timestamp first, so you can match it in the logs:
curl -sI https://example.com/failing-page
date -u
The HTTP स्टेटस चेकर confirms that the status really is 500 and not, for example, a 404 rendered by a custom error template or a 200 with an error message inside it.
Step 1: Read the right log
Different stacks log in different places. Check the ones that apply, newest entries last.
| Stack | Typical log location |
|---|---|
| Apache (Debian/Ubuntu) | /var/log/apache2/error.log |
| Apache (RHEL/CentOS/Alma) | /var/log/httpd/error_log |
| nginx | /var/log/nginx/error.log |
| PHP-FPM | /var/log/php8.3-fpm.log (version varies) |
| PHP errors in a hosting panel | error_log file in the site directory, or the panel's "Errors" page |
| WordPress with debug on | wp-content/debug.log |
| IIS | Event Viewer, failed request tracing, %SystemDrive%\inetpub\logs |
| Node / Python app | Process manager output, journalctl -u yourapp |
sudo tail -n 50 /var/log/apache2/error.log
sudo tail -f /var/log/nginx/error.log # then reload the page
On shared hosting, look in cPanel's "Errors" or "Metrics", Plesk's "Logs", or an error_log file in the document root. If PHP errors are not being logged anywhere, enable logging in php.ini or .user.ini:
display_errors = Off
log_errors = On
error_log = /home/youraccount/logs/php_errors.log
Step 2: Match the log message to the cause
PHP fatal errors
Lines such as PHP Fatal error: Uncaught Error: Call to undefined function or Class "X" not found mean code is calling something that does not exist. This is usually after a plugin, theme or version upgrade: a PHP version that is too new or too old for the code, a missing PHP extension (mbstring, curl, intl, mysqli), or a half-uploaded file. Check which PHP version the site really runs (php -v on the CLI can differ from the web version; use a phpinfo() page briefly, or your panel's PHP selector) and install the missing extension.
Allowed memory size of 134217728 bytes exhausted means the script hit the memory_limit. You can raise it, but first check what consumed it: an import, an image-processing plugin or a runaway loop. The remedy for a loop is code, not more memory.
.htaccess and Apache configuration
On Apache, a syntax error in .htaccess returns 500 for the whole directory tree. The Apache error log says things like Invalid command 'php_value', perhaps misspelled or defined by a module not included or .htaccess: RewriteEngine not allowed here. Common triggers:
- Pasting PHP settings (
php_value) into.htaccessafter switching frommod_phpto PHP-FPM, where those directives are invalid. Use.user.iniinstead. - A rewrite rule with a typo or an infinite internal loop (the log says
Request exceeded the limit of 10 internal redirects). AllowOverrideset too restrictively for the directives used.
Test by renaming the file and reloading the page:
mv .htaccess .htaccess.bak
If the site recovers, restore the file and add rules back until the error returns. For WordPress, regenerate it by saving Settings, Permalinks, or use the standard default block.
nginx configuration and upstream issues
nginx returns 500 for rewrite loops (rewrite or internal redirection cycle while internally redirecting), for try_files pointing to a missing fallback, and when an error page directive itself fails. Validate the config before applying:
sudo nginx -t
If nginx proxies to an application and you instead see 502 or 504, switch to fix 502 Bad Gateway or fix 504 Gateway Timeout.
Permissions and ownership
A script that the server user cannot read or execute usually causes 403, but misconfigured suEXEC or suPHP setups return 500 instead, with log entries like Premature end of script headers or SoftException ... is writable by group. Typical safe permissions for web content are 755 for directories and 644 for files, owned by the account user, and never 777. Fix recursively with care:
find /var/www/example.com -type d -exec chmod 755 {} \;
find /var/www/example.com -type f -exec chmod 644 {} \;
Database connection failures
Some applications report a 500 when the database is unreachable or credentials are wrong (WordPress usually shows its own "Error establishing a database connection" page, but custom code often does not). Verify with the credentials in the config file:
mysql -h localhost -u dbuser -p dbname -e "SELECT 1;"
sudo systemctl status mysql
CGI and script problems
For CGI or Perl scripts, Premature end of script headers has several causes: the script did not print a Content-Type header, it crashed before output, it has Windows line endings (\r\n) in the shebang line, or it is not executable. Run the script from the command line to see its real error.
Step 3: WordPress-specific routine
WordPress sites hit 500 mostly after plugin or theme changes, PHP upgrades or memory limits. A methodical sequence:
- Turn on debug logging in
wp-config.php:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
Reload the failing page and read wp-content/debug.log. The path in the stack trace names the guilty plugin or theme directory.
- Disable all plugins without needing the dashboard by renaming
wp-content/pluginstoplugins.offthrough FTP or the file manager. If the site returns, rename the folder back and disable plugins one at a time (or rename individual plugin folders) to find the culprit. - Switch theme by renaming the active theme's folder; WordPress falls back to a default theme if one is installed.
- Check PHP version compatibility. A plugin that does not support the latest PHP release is a common cause after a host-initiated upgrade. Switching back to the previous supported version is a legitimate stop-gap while you update or replace the plugin.
- Raise memory only if the log shows exhaustion:
define( 'WP_MEMORY_LIMIT', '256M' );inwp-config.php, subject to the host's own cap. - Restore a backup from before the first error if the above fails.
Remember to turn WP_DEBUG off when you are done.
Step 4: IIS and ASP.NET
IIS often returns a substatus in the logs and in the error page when viewed locally: 500.19 indicates a configuration problem (invalid web.config, or a section locked at a higher level, or a missing URL Rewrite module), 500.0 is an unhandled application error, and 500.21 points to a handler or module problem. Check Event Viewer, enable Failed Request Tracing for the failing URL, and look at the application's own logs. Turn on detailed errors temporarily by setting <httpErrors errorMode="Detailed" />, and turn them off again afterwards.
Step 5: Rule out the edge
If the page is behind a CDN or WAF, a 500 might come from the origin or from the edge itself. Compare responses with and without the CDN, using the techniques in fix 502 Bad Gateway, and compare headers with the HTTP Header Checker. Cloudflare's own 5xx pages, such as 500 "Internal server error" from Cloudflare, are different from a 500 that the origin returns and Cloudflare relays; the page branding tells you which is which. A redirect loop can also masquerade as a server failure, so test the chain with the रीडायरेक्ट चेकर.
Intermittent 500 errors
If errors appear for some requests only, think about what differs: the URL, the logged-in state, the specific user, the time of day, or which server in a pool handled it. Likely causes are an application bug on a single code path, one server in a cluster with a stale deployment, a cache poisoned with a bad response, or resource exhaustion that affects only the heaviest requests. Correlate by timestamp in the access log and error log, and add a request ID header at the proxy if you have several layers. Pay attention to a spike in 500s right after a deploy: rolling back first and debugging afterwards is the quickest way to restore service.
Quick decision path
- Confirm the status with
curl -Iand note the time. - Read the newest lines of the application, PHP and web server error logs.
- Syntax or config error: fix or revert the last change, run
nginx -torapachectl configtest. - PHP fatal: identify plugin, theme or version mismatch, then roll back or update.
- Memory exhausted: find the heavy operation before raising limits.
- No logs available: enable PHP logging, or use the host's panel.
- Still unresolved and the logs say nothing: contact your host with the timestamps.
When to call your host
On shared hosting, contact support if there are no error logs to read, if the error_log points to server-side modules or limits (suEXEC, LVE, mod_security), or if the 500 began without any change on your side. A ModSecurity rule can trigger a 500 or 403 on legitimate requests; the host can look up the rule ID in the audit log and whitelist it. Give them the URL, the UTC time, and what you have tried.
अगले कदम
Related tools and guides:
- HTTP स्टेटस चेकर to confirm the real status code
- HTTP Header Checker to inspect headers
- रीडायरेक्ट चेकर to rule out loops
- वेबसाइट हेल्थ चेक
- Why is my website down?
- Fix 503 Service Unavailable
सामान्य प्रश्न
What does a 500 Internal Server Error actually mean?
It means the server hit an unexpected condition and could not complete the request, and it does not have a more specific status to report. The real cause is typically in a server or application error log, not in the browser.
Is a 500 error my fault as a visitor?
Not usually. The failure happens on the server. You can try again later or clear cookies in case of a session problem, but only the site owner can fix the underlying issue.
Can a bad .htaccess file really take down the whole site?
Yes. Apache reads .htaccess on every request in that directory tree, so a syntax error or an unsupported directive causes a 500 for everything it covers. Renaming the file is a fast way to test.
Why did my site start showing 500 after my host updated PHP?
A newer PHP version can break plugins, themes or old code that use removed functions or stricter behavior, and missing extensions can have the same effect. Check the PHP error log, and either update the code or switch the site to the previous supported version while you fix it.
How do I stop 500 errors from reaching customers in the first place?
Test deployments in staging, keep backups and a rollback plan, and monitor the site externally so you notice failures immediately. The अपटाइम मॉनिटर can alert you when a page returns an error status.
Get notified when this guide updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.