How to fix a 500 Internal Server Error
Short answer: a 500 error means the server hit a problem it couldn't explain to the browser. The fastest fix is to read the server error log, which names the real cause. The most common causes are a broken .htaccess file, a plugin or code error, wrong file permissions, an exhausted PHP memory limit and a PHP version mismatch. Undo the most recent change first.
What a 500 error means
The browser asked for a page, and the server failed while building it. The problem is on the website's side, not the visitor's. Refreshing, clearing the cache or switching browsers won't fix it, though trying them rules out a temporary glitch.
If it's not your site, there's nothing you can fix. Wait a few minutes and try again, or tell the site owner.
Step 1: undo the last change
Most 500 errors appear right after something changed:
- a plugin, theme or package was installed or updated,
.htaccess,wp-config.php,.envor another config file was edited,- files were uploaded or a deploy ran,
- the hosting PHP version was changed.
Roll that change back first. If the site comes back, you've found the cause.
Step 2: read the error log
The log tells you the file and line that failed. Where to find it:
| Setup | Where the log is |
|---|---|
| Shared hosting (cPanel, hPanel, Plesk) | The Error logs section of the control panel, or error_log files in your site folders |
| WordPress | Add define('WP_DEBUG', true); and define('WP_DEBUG_LOG', true); to wp-config.php, then read wp-content/debug.log |
| Node.js app | Your process manager's logs, for example pm2 logs or your host's runtime log |
| Nginx / Apache server | Usually /var/log/nginx/error.log or /var/log/apache2/error.log |
Turn debugging off again when you're done, so visitors never see error details.
Step 3: check the usual suspects
A broken .htaccess file
One typo in .htaccess breaks the whole site on Apache and LiteSpeed. Rename it to .htaccess-old and reload. If the site works, the file was the problem. For WordPress, go to Settings → Permalinks and click Save to make a fresh one.
Plugins and themes (WordPress)
If you can't log in, rename wp-content/plugins to plugins-off over FTP or the file manager. If the site loads, rename it back and turn plugins on one by one until the error returns. Do the same with the theme by switching to a default theme.
PHP memory limit
Errors such as "Allowed memory size exhausted" mean PHP ran out of memory. Raise memory_limit in your host's PHP settings, for example to 256M, or add define('WP_MEMORY_LIMIT', '256M'); in WordPress.
PHP version
Older code can break on a newer PHP version, and newer code on an older one. Check what your theme, plugins or framework require and set the matching version in the control panel.
File permissions
On most Linux hosting, folders should be 755 and files 644. Files set to 777 are often refused by the server for security reasons.
Code and JSON errors
A syntax error in PHP, JavaScript or a config file causes a 500 error. For JSON config files, paste them into the JSON formatter. It shows the exact line. See how to fix invalid JSON.
Step 4: if it's still broken
- Restore the latest backup from your hosting panel.
- Ask your host's support team. Send them the time of the error and the log lines.
- If the site runs on a VPS, check disk space. A full disk causes strange 500 errors.
Related errors
- 403 Forbidden: the server refuses access.
- 404 Not Found: the page doesn't exist.
- Too many redirects: a redirect loop.
Questions
Does a 500 error hurt SEO?
A short outage doesn't. If search engines keep getting 500 errors for days, they crawl the site less and may drop pages from results. Fix it quickly and check Google Search Console afterwards.
What's the difference between 500, 502 and 503?
A 500 is a generic failure inside the site. A 502 Bad Gateway means a proxy got a bad answer from the app behind it, often because the app crashed. A 503 Service Unavailable means the server is overloaded or in maintenance.
Can a visitor fix a 500 error?
No. It's a server problem. A visitor can only reload later.