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.
- Browser
- DNS
- HTTPS
- CDN or firewall
- Web server (this error comes from here)
- PHP
- WordPress
- Database and files
What causes it
The .htaccess file has a line the server cannot read
CommonA 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.
A plugin or the theme has a PHP error
CommonCode 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.
Something on the server itself
SometimesWrong permissions on files or folders, a limit reached on the hosting plan, or a fault in the server's own configuration.
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.
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.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 WordPressStep 3: Reload the site
If it loads, a line in the old file was the cause.
Step 4: Put your other rules back with care
Open the copy you saved. Anything outside the
# BEGIN WordPressand# END WordPresslines 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.
Step 1: Turn the debug log on
In
wp-config.php, find the linedefine( 'WP_DEBUG', false );and replace it with these three.wp-config.phpdefine( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false );Step 2: Load the page that fails, then open the log
Open
wp-content/debug.logand find the newest line that begins "PHP Fatal error". It ends with the path of the file that failed.Step 3: Act on what it names
- A path through
wp-content/plugins/orwp-content/themes/: that plugin or theme is at fault. Switch it off as described for the white screen of death. - "Allowed memory size exhausted": the page ran out of memory. See how to fix "Allowed memory size exhausted".
- A path through
Step 4: Turn the debug log off
Put the line back to
define( 'WP_DEBUG', false );and deletedebug.log.
With WP-CLI:
wp config set WP_DEBUG true --raw
wp config set WP_DEBUG_LOG true --raw
wp config set WP_DEBUG_DISPLAY false --rawAnd when you have read the log:
wp config set WP_DEBUG false --raw
wp config set WP_DEBUG_LOG false --rawAsk the host to check the server's log
- Easy
- No risk
- About 15 minutes
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.
Step 2: If you cannot see one, ask support
Tell them the site returns a 500 error, that you have replaced
.htaccesswith 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.
- GuideLocked out of WordPress admin: find which lockout you have and get back in
- GuideSlow WordPress admin: how to find the cause and fix it
- ResourceWooCommerce checkout is down: a runbook
- GuideWordPress site not showing up on Google: what to check, in order
- Guideadmin-ajax.php high CPU usage in WordPress: how to find what is calling it
- GuideHow to change WordPress permalinks without breaking your old links

