Error 500 Internal Server Error: finding the cause, step by step

The short answer: error 500 means “something went wrong on the server and I cannot say what”. The cause is almost always in the error log, and almost always one of these four: an error in the PHP code, an invalid rule in .htaccess, wrong permissions, or a PHP version that does not suit. The log tells you which.

1. Read what the server recorded

In cPanel, the Errors page shows the site’s latest errors; and, in the site’s folder, there may be a file called error_log. Look for the line from the time the error appeared. See Reading the Errors and Raw Access pages in cPanel.

What the log says The cause What to do
PHP Parse error / Fatal error, with a file and a line An error in the code, after an edit or an update. Fix the line shown, or put the earlier file back. In WordPress, see Common WordPress errors.
Allowed memory size exhausted The program needed more memory than the limit. Fixing “Allowed memory size exhausted”.
Invalid command or .htaccess: ... A rule in the .htaccess file that the server does not recognise. Rename the .htaccess (for example, to .htaccess-test) and see whether the error goes away: .htaccess for PHP projects.
Premature end of script headers A script that did not return the right header, or has the wrong permissions. See File permissions. For Perl/CGI, see Perl and CGI scripts.
Call to undefined function or missing classes PHP lacks an extension, or the version is too old (or too new). Change the PHP version and check the extensions: How to change your PHP version.
The log is empty The error comes from before PHP (the .htaccess) or has not been recorded yet. Try the .htaccess test, and repeat the error so the log updates.

2. If the log does not help

1 Switch off the extras: in WordPress, deactivate the plugins and the theme, even without getting into the dashboard: Disabling plugins, even when you cannot get in.
2 Put back the last version that worked, from the backup, into a test folder: Your own backup.
3 Check the permissions: folders 755 and files 644. A PHP file with 777 can give a 500 on many servers.
4 See whether it was the resource limit: Entry processes. That one usually gives a different error (508), but sometimes appears as a 500.
Do not delete the .htaccess to “see if it fixes it”: rename it and keep a copy. In WordPress, the page links depend on it. For the other errors in the same group, see Website errors explained and Error 503 and the 5xx family.

Did this and error 500 persists? Open a ticket with the address, the time of the error and the log line.

Open a support ticket

SEE ALSO

Website errors explained: 500, 403, 404, 508 and what to do

Reading the Errors and Raw Access pages in cPanel when a page fails

Error 403 Forbidden: permissions, .htaccess and blocked IPs

Your site is down: what to check first

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from $6.60/mo (3-year plan, with coupon)

See plans
  • 0 Users Found This Useful
Was this answer helpful?