Skip to content

How to fix the 500 Internal Server Error in WordPress

A 500 error is the web server saying something went wrong without saying what. On a WordPress site the two usual causes are a damaged .htaccess file and a PHP error in a plugin or theme. Replacing .htaccess with WordPress's standard one takes two minutes and settles which it is.

By
WP Ministry
Published
Tested on
WordPress 7.1.3, PHP 8.3.35

In short

  • A 500 error is a general failure notice from the server. The real cause is in the server's error log.
  • Try the .htaccess file first. It is the quickest thing to rule out and a common cause.
  • If that changes nothing, a plugin or the theme is failing. The error log names it.
  • Your content is not affected by any of this.

"500 Internal Server Error" is the web server's way of saying that something failed and it will not say what in public. It is not one fault but a label for many. The actual cause is written to an error log, and the fixes below are ordered by how often each cause turns up and how quickly it can be ruled out.

Your posts, pages and settings are not affected.

Where it goes wrong

A page request passes through each of these in turn. This one comes from the web server.

  1. Browser
  2. DNS
  3. HTTPS
  4. CDN or firewall
  5. Web server (this error comes from here)
  6. PHP
  7. WordPress
  8. Database and files

What causes it

  • The .htaccess file has a line the server cannot read

    Common

    A plugin, or an edit made by hand, left a rule in .htaccess that the web server does not understand. One bad line stops every page.

    Fix: Replace .htaccess with WordPress's standard one

  • A plugin or the theme has a PHP error

    Common

    Code in a plugin or theme failed. WordPress usually reports this as a "critical error", but it reaches the visitor as a 500 all the same.

    Fix: Find the PHP error behind it

  • Something on the server itself

    Sometimes

    Wrong permissions on files or folders, a limit reached on the hosting plan, or a fault in the server's own configuration.

    Fix: Ask the host to check the server's log

How to fix it

Replace .htaccess with WordPress's standard one

  • Easy
  • Back up first
  • About 5 minutes
  • Steps tested on WordPress 7.1.3

This applies to sites on Apache or LiteSpeed, which is most shared hosting. A site on nginx has no .htaccess file: go to the next fix.

  1. Step 1: Find .htaccess in the site's main folder

    It sits beside wp-config.php. Its name begins with a dot, so turn on "Show hidden files" in your file manager if you cannot see it.

  2. Step 2: Replace everything in it with this

    This is what WordPress itself writes for a site at the root of its domain.

    .htaccess
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
  3. Step 3: Reload the site

    If it loads, a line in the old file was the cause.

  4. Step 4: Put your other rules back with care

    Open the copy you saved. Anything outside the # BEGIN WordPress and # END WordPress lines was added by a plugin or by hand. Add those sections back one at a time, reloading after each, until you find the one that breaks the site.

If WordPress is installed in a subfolder, such as example.com/blog, do not paste the block above. Rename .htaccess to .htaccess-old instead, then go to Settings, then Permalinks in the dashboard and press Save Changes. WordPress writes a fresh file with the right paths.

To undo it: Put your copy of the old .htaccess back.

Find the PHP error behind it

  • Takes care
  • Low risk
  • About 15 minutes
  • Steps tested on WordPress 7.1.3

If .htaccess was not the cause, a plugin or the theme is failing. WordPress will write the details to a log if you ask.

  1. Step 1: Turn the debug log on

    In wp-config.php, find the line define( 'WP_DEBUG', false ); and replace it with these three.

    wp-config.php
    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_LOG', true );
    define( 'WP_DEBUG_DISPLAY', false );
  2. Step 2: Load the page that fails, then open the log

    Open wp-content/debug.log and find the newest line that begins "PHP Fatal error". It ends with the path of the file that failed.

  3. Step 3: Act on what it names

  4. Step 4: Turn the debug log off

    Put the line back to define( 'WP_DEBUG', false ); and delete debug.log.

With WP-CLI:

bash
wp config set WP_DEBUG true --raw
wp config set WP_DEBUG_LOG true --raw
wp config set WP_DEBUG_DISPLAY false --raw

And when you have read the log:

bash
wp config set WP_DEBUG false --raw
wp config set WP_DEBUG_LOG false --raw

Ask the host to check the server's log

  • Easy
  • No risk
  • About 15 minutes
  1. Step 1: Look for an error log in your hosting panel

    Many panels have an "Errors" or "Error log" page showing the server's most recent errors. The line written at the moment you loaded the page is the one that matters.

  2. Step 2: If you cannot see one, ask support

    Tell them the site returns a 500 error, that you have replaced .htaccess with the standard one and that WordPress's debug log shows nothing. Ask what the server's error log says for your site.

When to get help

If .htaccess is the standard one, the debug log is empty and the 500 is still there, the cause is in the server's own logs, which most hosting plans only show to the host. Ask them, and tell them what you have already ruled out.

Common questions

Is a 500 error my fault or my host's?

Usually the site's: a rule in .htaccess, or code in a plugin or theme. The fixes above rule those out. What is left is the host's.

Why does it only happen on some pages?

Different pages run different code. A fault in one plugin's feature shows only on the pages that use it, which is a strong hint about which plugin to look at.

Will a 500 error hurt my search ranking?

A short outage does not. Search engines come back and try again. An error that lasts for days can lead to pages being dropped, so it is worth fixing promptly.

More on this subject

Would you rather we fixed it?

Emergency Fix is $99. Site down or checkout broken. Goes to the front of the queue. No fix, no fee. 30-day warranty. It starts with a free diagnosis.