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.
On this page
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 › 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 shows | Cause | Go to step |
|---|---|---|
.htaccess: Invalid command, RewriteRule: bad flag | .htaccess | 2 |
PHP Fatal error, PHP Parse error | PHP code | 3 |
Permission denied, is writable by group | Permissions | 4 |
Premature end of script headers | PHP crashed or timed out | 3 and 5 |
2. .htaccess
- In System Info & Files › File Manager, show hidden files and rename
.htaccessto.htaccess-off. - Reload. If the site works, the problem is in that file.
- 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.
- Parse error — a typo in an edited file. Undo the edit.
- Fatal error in a plugin or theme — disable it by renaming its folder. “There has been a critical error on this website”
- Memory exhausted — “Allowed memory size exhausted” PHP error
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).
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.
Prefer to follow along?
- Diagnose a 500 Internal Server Error
Intermediate · 20 min - Deploy a Laravel application to Traxio
Advanced · 60 min - Make your site secure with HTTPS
Beginner · 15 min
Common questions
What does a 500 Internal Server Error mean?
Something failed while the server was building the page, and the real reason is in the error log — the browser deliberately doesn’t show it. On shared hosting the usual causes are a .htaccess syntax error, a PHP fatal error or wrong file permissions.
Read the log before changing anything. Guessing at a 500 error is how people end up making three changes, fixing nothing and no longer knowing what state the site is in.
Spotted something out of date or unclear? Tell us and we’ll fix it.