# Fix WordPress 500 Internal Server Error

A 500 Internal Server Error is WordPress telling you something went wrong, but it won't say what. Unlike the white screen of death, you at least get an error code. The problem is that "500" covers a wide range of issues from corrupted .htaccess files to exhausted PHP memory.

The error typically appears as a plain white page with "500 Internal Server Error" or sometimes just "Internal Server Error" with no additional context.

Find the Real Error Message

Your first job is to see what the server is hiding. The 500 status is generic; the actual cause lives in your error logs.

Check Server Error Logs

The location depends on your hosting setup:

```bash # Apache (common locations) tail -50 /var/log/apache2/error.log tail -50 /var/log/httpd/error_log

# Nginx tail -50 /var/log/nginx/error.log

# cPanel tail -50 /home/username/logs/error_log

# Check multiple common locations find /var/log -name "*.log" -type f -exec grep -l "error" {} \; ```

Enable WordPress Debug Mode

Open wp-config.php and add these lines before /* That's all, stop editing! */:

php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

Now WordPress logs errors to wp-content/debug.log:

bash
tail -f wp-content/debug.log

Use WP-CLI to Check for Errors

```bash # Check if WordPress can even load wp eval 'echo "WordPress loaded successfully\n";'

# Check for PHP syntax errors in core files wp core verify-checksums

# Check database connection wp db check ```

Most Common Causes

1. Corrupted .htaccess File

The .htaccess file is the most common culprit for 500 errors. A single malformed rewrite rule can crash everything.

Quick fix:

```bash # Backup existing .htaccess cp .htaccess .htaccess.backup

# Create a fresh .htaccess cat > .htaccess << 'EOF' # BEGIN WordPress 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] # END WordPress EOF ```

Or regenerate via WordPress admin:

  1. 1.Go to Settings > Permalinks
  2. 2.Don't change anything
  3. 3.Click "Save Changes"

This regenerates a clean .htaccess file.

2. PHP Memory Limit Exceeded

The server error log will show something like:

bash
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted

Fix in wp-config.php:

php
define('WP_MEMORY_LIMIT', '256M');
define('WP_MAX_MEMORY_LIMIT', '512M');

Fix in php.ini (if you have access):

ini
memory_limit = 512M

Fix in .htaccess (Apache):

apache
php_value memory_limit 512M

Verify with WP-CLI:

bash
wp eval 'echo "Memory limit: " . ini_get("memory_limit") . "\n";'

3. PHP Version Incompatibility

Your server might have upgraded PHP, and older plugins or themes aren't compatible.

Check PHP version:

bash
php -v
wp eval 'echo "PHP version: " . phpversion() . "\n";'

Check for deprecated functions in error log:

bash
grep -i "deprecated\|fatal\|error" wp-content/debug.log | tail -20

If you see errors about deprecated functions, either update the problematic plugin/theme or downgrade PHP temporarily.

4. File Permission Issues

Wrong permissions on core files can trigger 500 errors.

Correct WordPress permissions:

```bash # Set directories to 755 find /var/www/html -type d -exec chmod 755 {} \;

# Set files to 644 find /var/www/html -type f -exec chmod 644 {} \;

# Set wp-content to 755 with proper ownership chmod -R 755 wp-content/ chown -R www-data:www-data wp-content/

# wp-config.php should be 600 or 640 chmod 600 wp-config.php ```

5. Corrupted Core Files

WordPress core files might be corrupted or incomplete.

Reinstall core files:

bash
wp core download --force
wp core update --force

This overwrites core files while preserving your content and configuration.

6. Plugin Conflict

A plugin throwing a fatal error will cause 500 errors across the site.

Disable all plugins via WP-CLI:

bash
wp plugin deactivate --all

If the site works now, reactivate plugins one by one:

bash
wp plugin activate plugin-slug
# Test site
wp plugin activate next-plugin-slug
# Test again

Disable via FTP if WP-CLI unavailable:

bash
mv wp-content/plugins wp-content/plugins-hold
mkdir wp-content/plugins

Move plugins back one at a time to identify the problem.

Server-Specific Issues

Nginx Configuration

Nginx doesn't use .htaccess, so check your site configuration:

```bash # Test Nginx configuration nginx -t

# Check error log tail -50 /var/log/nginx/error.log

# Common fix: increase buffers # In nginx.conf or site config: fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; ```

Apache Configuration

```bash # Check Apache configuration apachectl configtest

# Ensure AllowOverride is set # In site configuration: <Directory /var/www/html> AllowOverride All </Directory> ```

PHP-FPM Issues

```bash # Check PHP-FPM status systemctl status php8.1-fpm

# Restart if stuck systemctl restart php8.1-fpm

# Check PHP-FPM error log tail -50 /var/log/php8.1-fpm/error.log ```

Verification Steps

After applying your fix:

```bash # Test the frontend curl -I https://yourdomain.com # Should return HTTP/2 200

# Test wp-admin curl -I https://yourdomain.com/wp-admin/ # Should redirect to login or return 200

# Check for any remaining errors wp eval 'WP_CLI::success("WordPress is healthy");' ```

Quick Reference

Error Log MessageLikely CauseQuick Fix
Allowed memory size exhaustedMemory limitIncrease WP_MEMORY_LIMIT
RewriteCond: bad flag delimiters.htaccess syntaxRegenerate .htaccess
Permission deniedFile permissionsFix ownership/permissions
Class not foundMissing plugin fileReinstall plugin
Call to undefined functionPHP versionCheck compatibility

A 500 error is frustratingly vague, but the error logs always contain the real answer. Enable debugging, check those logs, and the fix becomes obvious.