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.

The 500 internal server error is one of the most frustrating WordPress problems because the message itself tells you almost nothing. You see a generic "Internal Server Error" or "500" page, or sometimes just a blank white screen.

It means something on the server has failed, but the server can't say exactly what. 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.

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.

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. 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.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.

Still seeing a 500 error?

If the error continues after these steps, there may be a server problem that needs access to logs and settings you can't reach from WordPress. Your hosting provider is the best first contact. My WordPress development service and emergency WordPress support can also help diagnose and fix persistent 500 errors.


  1. Debugging in WordPress, WordPress Advanced Administration Handbook. ↩ ↩

  2. How to change configuration settings, PHP Manual. ↩

  3. Apache HTTPD / .htaccess, WordPress Advanced Administration Handbook. ↩

  4. wp-config.php, WordPress Advanced Administration Handbook. ↩ ↩ ↩

  5. theme.php (validate_current_theme), WordPress source code on GitHub. ↩

  6. Changing file permissions, WordPress Advanced Administration Handbook. ↩ ↩

  7. update-core.php, WordPress source code on GitHub. ↩

  8. Upgrading, WordPress Advanced Administration Handbook. ↩

Adam Greenough

Written by Adam Greenough

Freelance web developer with over 15 years of experience building and fixing WordPress sites. I work with businesses across the UK on everything from emergency support to full builds.

Need emergency WordPress support today?

If your site is down, hacked or throwing errors, send me the details and I will assess the problem quickly. Support starts from £50, you will get a fixed quote before any work begins, and if I cannot fix the issue, you will not pay.