Fixing the WordPress 500 internal server error
How to diagnose and resolve the WordPress 500 internal server error by enabling debug mode, resetting .htaccess, increasing memory limits, disabling plugins and repairing the database.
A 500 internal server error in WordPress means something on the server has failed, but the server can't say exactly what. You see a generic "Internal Server Error" or "500" page, or sometimes just a blank white screen.
That makes it one of the most frustrating WordPress problems, because the message itself tells you almost nothing. In WordPress, the most common causes are a faulty .htaccess file, a plugin or theme problem, running out of PHP memory, wrong file permissions, a damaged database table or a server configuration problem.
The steps below work through each possibility, starting with the quickest checks. If you're seeing a 502, 503 or 504 error rather than a 500, those have different causes, covered in our guide to fixing 502, 503 and 504 errors. If you're seeing "There has been a critical error on this website", see our critical error guide.
Check with your hosting provider first
Before changing anything, check your hosting provider's status page and contact their support team. The error may be caused by something on the server that you can't control, such as a full disk, a stopped database service, a recent PHP version change or maintenance. Our guide to diagnosing a WordPress site that's down covers other checks outside WordPress, such as your domain and DNS.
Give them any error details you have and ask whether anything has changed on the server recently. Your host can also look at the server's error logs, which usually say exactly what failed. That can save a lot of guesswork.
Turn on debug logging
WordPress has a debug mode that records the specific PHP error behind the generic 500 page. It's often the fastest way to find the cause.
Open wp-config.php (in your WordPress root folder) via SFTP or your hosting file manager. Download a copy first, since a single stray character in this file can take the whole site offline, and the copy lets you put it straight back. Then add these lines just above the comment that reads /* That's all, stop editing! */:1
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
This tells WordPress to write errors to a log file rather than show them to visitors. Reload the page that was showing the error, then look in wp-content/debug.log.1 The error usually includes a file path, which tells you whether the problem is in a plugin, a theme or WordPress itself. Our guide to reading the WordPress debug log explains how to pick out the error that matters.
When you've finished, switch debugging off again by removing these lines (or setting WP_DEBUG to false) and delete debug.log. The log can reveal details about your site and server, and on many servers files in wp-content can be viewed by anyone who knows the address.
Reset .htaccess
On Apache and LiteSpeed servers, the .htaccess file controls how the server handles addresses, redirects and some access rules. If it's damaged or contains conflicting rules (often added by plugins), it can cause a 500 error across the whole site.
Connect via SFTP or your hosting file manager and rename .htaccess to .htaccess_old. Renaming rather than deleting keeps a copy of any custom rules you might need later. Then reload your site. If the error clears, the file was the problem.
A common culprit is a php_value line added to raise upload limits. Those lines only work when PHP runs as an Apache module and cause a 500 error on other setups.2 Our guide to fixing "The link you followed has expired" explains safer ways to change PHP limits.
To create a clean file, log into your dashboard, go to Settings→ Permalinks and click Save Changes without changing anything. WordPress writes a new .htaccess with its default rules. If the old file had other rules you still need, such as redirects or security rules, copy them back from .htaccess_old one block at a time, checking the site after each.
If you can't reach the dashboard, you can create the file by hand with WordPress's default rules.3 Our permalink troubleshooting guide has a copy of them, including what to change if WordPress is in a subfolder.
If your server runs Nginx, there's no .htaccess file. Nginx has its own configuration, which your hosting provider will need to check.
Check PHP memory
If the debug log mentions "Allowed memory size ... exhausted", a plugin, theme or process is using more memory than PHP allows (our guide to the memory exhausted error goes into more detail). WordPress's WP_MEMORY_LIMIT setting lets you ask for more:4
define( 'WP_MEMORY_LIMIT', '256M' );
Add it to wp-config.php (with a copy of the file saved first). It only works up to the limit your host allows, so if it makes no difference, ask your host whether they can raise the server's limit.
If raising the limit fixes the error, something on your site is using a lot of memory, and it's worth finding out what rather than just raising the limit and moving on. The debug log usually gives a clue.
Check plugins and your theme
Plugin and theme problems are among the most common causes of 500 errors, especially straight after an update. If you know which update caused it, our guide to recovering a site broken by an update covers rolling back.
If you can reach the dashboard, deactivate your plugins under Plugins→ Installed Plugins, then reactivate them one at a time, checking the site after each. Deactivating plugins switches their features off for visitors too (including shops, forms and security), so do it at a quiet time or on a staging copy if you can.
If you're locked out of the dashboard, connect via SFTP or your hosting file manager, go to wp-content/plugins/ and rename plugin folders one at a time (for example, from plugin-name to plugin-name-disabled), checking the site after each. WordPress can't load a plugin whose folder has been renamed. Rename the folders back when you've finished, then check each plugin is active again under Plugins.
To rule out your theme, rename your active theme's folder inside wp-content/themes/. WordPress then switches to its default theme, if one is installed.5 This is a real theme change that visitors will see. When you've finished, rename the folder back, reactivate your theme under Appearance→ Themes and check your menus and widgets are still in place.
Check file permissions
WordPress's guidance is that folders should normally be 755 (or 750) and files 644 (or 640).6 If permissions have been changed by a migration tool, a plugin or someone editing files, the server may fail to run files and return a 500 error.
Recursive permission changes are easy to apply too broadly, and some files may be set more strictly on purpose, so take a backup first and ask your host if you're unsure. They can usually check and fix permissions for you. Never set permissions to 777. WordPress's documentation says no folders should ever be 777,6 and some hosts refuse to run files with such open permissions, which can itself cause a 500 error.
Repair the database
A damaged database table can cause a 500 error, particularly if it's a table WordPress needs on every page, such as wp_options.
Take a backup of your database before running a repair. Repairs usually help, but on a badly damaged table they can lose data, and a backup is your only way back. Our guide to the database connection error covers database problems in more depth.
WordPress has a built-in repair tool, which is switched off by default. To switch it on, add this line to wp-config.php:4
define( 'WP_ALLOW_REPAIR', true );
Then visit https://example.com/wp-admin/maint/repair.php (replacing example.com with your domain) and run the repair. Anyone can use this page without logging in while the setting is on,4 so remove the line from wp-config.php as soon as you've finished.
Reinstall WordPress core files
If nothing else has worked, WordPress's own files may be damaged or incomplete, for example after a failed update.
Take a backup first. Reinstalling overwrites WordPress's core files, so any changes someone has made to them (which shouldn't happen, but sometimes does) will be lost.
If you can reach the dashboard, go to Dashboard→ Updates and click the Re-install version button (if WordPress says another update is in progress, see our guide to clearing the update lock).7 This replaces WordPress's core files without touching your themes, plugins and uploads in wp-content, or your wp-config.php file.
If you can't reach the dashboard, you can replace the core files by hand with a fresh copy of the same WordPress version from wordpress.org. WordPress's handbook describes the manual process.8 Take particular care not to overwrite or delete your wp-content folder or wp-config.php, since these hold your site's content and settings. If you're not confident, this is a job for your host or a developer.
Common questions
Will a 500 error delete my posts or pages?
Usually not. A 500 error means something failed on the server while building the page, and your posts, pages and settings stay in the database. Once the faulty file, plugin or setting is fixed, the site normally comes back as it was. The exception is a badly damaged database table, which is why you should back up the database before running a repair.
Is a 500 error my host's problem or my site's?
It can be either. A full disk, a stopped database service or a recent PHP version change are on your host's side, while .htaccess rules, plugins, themes and memory limits are things you can check yourself. Contact your host first, since their server error logs usually show exactly what failed.
What's the difference between a 500 error and a critical error?
They often have similar causes. When a PHP error stops WordPress, WordPress usually catches it and shows "There has been a critical error on this website", while a plain 500 page comes from the server itself, for example when .htaccess contains a rule it can't handle. If you're seeing the critical error message, our critical error guide covers recovery mode and debugging.
Why does the 500 error keep coming back?
Usually because the underlying cause is still there. Raising the PHP memory limit or resetting .htaccess can clear the error for a while, but a plugin that uses a lot of memory, or one that keeps adding conflicting rules to .htaccess, will bring it back. Check the debug log when the error returns, since it normally names the plugin or theme responsible.
Still seeing a 500 error?
If you've worked through these steps and the error is still there, the cause may be in server logs and settings you can't reach from WordPress, so your hosting provider is the best first contact. If they can't pin it down, my emergency WordPress support can find the real error and fix it. Many fixes are £50 all in, you'll get a fixed quote before I start and it's no fix, no fee. My WordPress development service can also help with errors that keep coming back.
Debugging in WordPress, WordPress Advanced Administration Handbook. ↩ ↩
How to change configuration settings, PHP Manual. ↩
Apache HTTPD / .htaccess, WordPress Advanced Administration Handbook. ↩
wp-config.php, WordPress Advanced Administration Handbook. ↩ ↩ ↩
theme.php (validate_current_theme), WordPress source code on GitHub. ↩
Changing file permissions, WordPress Advanced Administration Handbook. ↩ ↩
update-core.php, WordPress source code on GitHub. ↩