500 Internal Server Error: how to fix it

Find the real cause of a 500 error: read the error log, then check .htaccess, PHP errors, permissions and PHP version in order.

TroubleshootingIntermediate2 min readUpdated

Does this match what you’re seeing?

  • The page says 500 Internal Server Error
  • The whole site or one page shows a 500
  • It started after editing .htaccess, updating or changing PHP

A 500 means the server hit a problem it won’t describe to visitors. The description is in the error log.

1. Read the error log

Open System Info & Files then Site Summary / Statistics / Logs, choose the domain’s error log, reproduce the 500, and read the newest lines. Viewing website statistics and logs in DirectAdmin

Log showsCauseGo to step
.htaccess: Invalid command, RewriteRule: bad flag.htaccess2
PHP Fatal error, PHP Parse errorPHP code3
Permission denied, is writable by groupPermissions4
Premature end of script headersPHP crashed or timed out3 and 5

2. .htaccess

  1. In System Info & Files then File Manager, show hidden files and rename .htaccess to .htaccess-off.
  2. Reload. If the site works, the problem is in that file.
  3. Restore it and remove recently added rules one at a time, or restore a backup copy.

WordPress: after removing the file, re-save Settings → Permalinks to regenerate a clean one. What is .htaccess? A practical guide

3. PHP errors

The log gives the file and line.

Understanding PHP error messages

4. Permissions

Folders should be 755, files 644. Files or folders writable by everyone (777) can be refused by the server. File permissions explained (644, 755 and why never 777)

5. PHP version

If the 500 began after switching PHP version, switch back, then find the incompatible code. How to change the PHP version in DirectAdmin

Nothing in the log?

Check the error log files inside public_html too (How to find PHP errors (error logs and display_errors)), and whether other sites or webmail on the account work (Is it my website or the server? How to tell).

Questions people ask

What causes a 500 Internal Server Error?

Most often a mistake in .htaccess, a fatal PHP error in the site’s code, incorrect file permissions or an incompatible PHP version. The domain’s error log names the exact cause.

Popular

Tip: press / to search from any pageSee all results