What a 500 Internal Server Error means
A 500 Internal Server Error means the server hit an unexpected condition that stopped it from completing the request. RFC 9110 defines it that way, and it is the generic catch-all for server-side failures: the server knows something went wrong but has no more specific 5xx code to send. The browser page tells you almost nothing. The real cause is written to a log on the server.
Each common cause leaves a different message in the error log, so read the log before you change anything.
Quick-fix checklist for site owners
- Note the exact time and URL of the error, then reload once. A 500 that clears straight away was often a deploy or restart in progress.
- Read the error log for that time. In cPanel, open Metrics and then Errors. On a VPS, run
sudo tail -n 50on the Apache, Nginx or PHP-FPM log listed below. - Undo your last change: a plugin or theme update, an edit to
.htaccess, a PHP version switch or a code deploy. - Rename
.htaccessto.htaccess.bakand test again. If the site loads, the problem is in that file. - Check permissions: files
644, folders755, and nothing set to777. - Check the PHP version selected for the domain matches what your application supports, and that its required extensions are enabled.
Where to find the real error
| Server | Where the log is |
|---|---|
| cPanel shared hosting (Apache or LiteSpeed) | Metrics > Errors in cPanel shows the latest web server errors for your account; PHP may also write an error_log file in the folder of the script that failed |
| Apache on Ubuntu or Debian | /var/log/apache2/error.log |
| Apache on AlmaLinux or Rocky | /var/log/httpd/error_log |
| Nginx | /var/log/nginx/error.log in the standard Linux packages, set by the error_log directive |
| PHP-FPM | The error_log setting in the FPM configuration, for example /var/log/php8.3-fpm.log on Ubuntu |
| Applications | Their own logs, for example storage/logs/laravel.log in Laravel or wp-content/debug.log in WordPress once debug logging is on |
To watch errors as they happen while you reload the page:
sudo tail -f /var/log/nginx/error.log /var/log/php8.3-fpm.log
Do not turn on display_errors on a live site to see the message. It shows file paths and sometimes credentials to every visitor. Log the error instead.
Cause 1: a broken .htaccess directive
Apache and LiteSpeed read .htaccess on every request. The Apache documentation says a directive with a syntax error, or one that is not permitted in .htaccess by the server's AllowOverride setting, produces a 500. The log line names the file and the problem:
/home/user/public_html/.htaccess: Invalid command 'RewriteEngin', perhaps misspelled or defined by a module not included in the server configuration
/home/user/public_html/.htaccess: Options not allowed here
Fix the line or remove it. A common trigger is pasting rules that need a module the server does not load, such as php_value lines on Apache where PHP runs through PHP-FPM or CGI rather than as an Apache module (LiteSpeed does accept them). Change PHP settings from the hosting panel or a .user.ini file instead. Nginx does not read .htaccess at all, so on Nginx those rules must be rewritten in the server block.
Cause 2: PHP fatal error or memory exhaustion
When PHP stops on a fatal error before sending any output and display_errors is off, the server returns a 500. Typical log lines:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)
PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect()
PHP Fatal error: Maximum execution time of 30 seconds exceeded
- Memory exhausted. The script needed more than
memory_limit(134217728 bytes is 128M). Raise it moderately, for example to 256M, and find out what is using the memory; a loop or an import that loads everything at once is the usual reason. - Undefined function or class. Code written for an older PHP version, or a missing extension. See cause 4.
- Execution time exceeded. The script ran past
max_execution_time. Move long jobs such as imports and backups out of the web request, for example to a cron job.
Cause 3: wrong file permissions or ownership
On hosting where PHP and CGI scripts run as your own user, the server checks permissions before it runs anything. Apache's suEXEC documentation lists the checks: the script and its directory must not be writable by anyone except the owner, and the owner must match the user the script runs as. A file set to 777, or one owned by root after an upload over SSH, fails those checks and returns a 500.
Set the standard permissions from the site's root folder. These commands are recursive and cannot be undone, so first check with pwd that you are in the site's own folder (for example public_html), never / or your whole home directory:
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
chmod 600 wp-config.php # or 640 if your setup needs group read
The file command removes the execute bit from everything, so set any CGI scripts back to 755 afterwards (see cause 5).
On a VPS you manage yourself, fix ownership too, replacing the user and group with the account that runs PHP. Do not run this on cPanel hosting, where the panel sets ownership for you:
sudo chown -R siteuser:siteuser /home/siteuser/public_html
Never use 777 to make an error go away: any process on the server could then change your files.
Cause 4: wrong PHP version or a missing extension
A PHP upgrade removes old functions, and an older application may stop with an undefined function error. The reverse also happens: a new plugin needs PHP 8 and the domain still runs 7.4. Errors such as Call to undefined function curl_init() or Class "ZipArchive" not found mean the extension that provides that function is not enabled.
On cPanel hosting, change the PHP version and tick the extension for that domain in the panel. On a VPS, install the package, for example on Ubuntu:
sudo apt install php8.3-curl php8.3-zip php8.3-mbstring php8.3-intl
sudo systemctl restart php8.3-fpm
Check what is loaded with php -m, remembering that command-line PHP can be a different version from the one serving the site.
Cause 5: CGI scripts and suEXEC
Perl, Python or shell scripts run through CGI return a 500 if they print anything before the HTTP headers, have Windows line endings, name a wrong interpreter path on the first line, or are not executable. Apache 2.4 typically logs End of script output before headers. Make the script executable with chmod 755, convert line endings with dos2unix script.cgi, and check the first line, for example #!/usr/bin/perl. On suEXEC servers the ownership rules in cause 3 apply as well.
Cause 6: Nginx configuration and timeouts
Nginx itself returns a 500 for some configuration mistakes. A common one is a rewrite loop, logged as rewrite or internal redirection cycle while internally redirecting, usually from a try_files line whose last fallback leads back to itself. Test changes before reloading:
sudo nginx -t && sudo systemctl reload nginx
If the backend is down or too slow rather than failing, you will usually see a 502 Bad Gateway or 504 Gateway Timeout instead of a 500.
WordPress checks
In WordPress, a 500 is nearly always a plugin, a theme, memory or .htaccess. Work through these in order:
- Turn on logging in
wp-config.php, above the line that says to stop editing:define( 'WP_DEBUG', true );,define( 'WP_DEBUG_LOG', true );anddefine( 'WP_DEBUG_DISPLAY', false );. Reload the page and readwp-content/debug.log. The file can be opened by anyone who knows its address, so when you are done set these back to false and deletedebug.log. - Rename
wp-content/pluginstoplugins-off. If the site returns, log in and open the Plugins screen so WordPress deactivates the missing plugins, rename the folder back, then reactivate plugins one at a time until the error returns. - Switch to a default theme by renaming the active theme's folder. WordPress falls back to a default theme such as Twenty Twenty-Five only if one is installed in
wp-content/themes. - Regenerate
.htaccessby saving Settings > Permalinks once the dashboard loads. - If the log shows memory exhaustion, raise
WP_MEMORY_LIMITinwp-config.phpand the PHPmemory_limit.
Visitor side vs site owner side
As a visitor, nothing on your device causes a 500. Reload after a minute or two, and if it persists, tell the site owner the page address and the time.
As the owner, the log is the starting point every time. If the error began after moving to a new host, compare PHP versions, extensions, file ownership and .htaccess rules between the old and new servers.
Fixing a 500 error on Bigdomainhost
Web & cPanel hosting and WordPress hosting run on LiteSpeed in Mumbai with cPanel, so the error log is under Metrics > Errors, and PHP 5.6 to 8.4 is selectable per domain with the common extensions available as checkboxes. Every plan includes 30 days of free backups, which helps if you need to roll back a change that broke the site.
On a KVM VPS you have full root access, so the commands above work as written on the Ubuntu, Debian, Rocky and AlmaLinux images, and the out-of-band console in the control panel still gets you in if a change locks you out. The VPS documentation covers access and networking. If you cannot find the cause, call or WhatsApp +91 75994 50220 or email support@bigdomainhost.com with the URL and the time of the error.
Sources (checked )
- IETF: RFC 9110: HTTP Semantics, section 15.6.1 500 Internal Server Error
- Apache HTTP Server: Apache HTTP Server Tutorial: .htaccess files
- Apache HTTP Server: suEXEC Support
- nginx.org: Core functionality: error_log
- PHP Manual: Description of core php.ini directives
- WordPress Developer Resources: Debugging in WordPress