Troubleshooting Common WordPress Errors: A Step by Step Guide

1 Oct

Understanding Why WordPress Errors Happen

WordPress is built on PHP and MySQL, and it relies on a collection of themes, plugins, and server configurations. When any part of that stack misbehaves, the site can show an error message or simply stop loading. Knowing the most frequent culprits helps you narrow down the cause quickly.

Getting Ready Before You Start Fixing

Before diving into any troubleshooting steps, protect your data and create a safe environment for testing.

  • Take a full backup of your site files and database. Many hosting providers offer one‑click backups; otherwise use a plugin like UpdraftPlus or manually download via FTP and export the database through phpMyAdmin.
  • Enable WP_DEBUG in your wp-config.php file. Change the line that reads define( 'WP_DEBUG', false ); to true and add define( 'WP_DEBUG_LOG', true ); to store messages in a debug.log file inside the wp-content folder.
  • If you can still access the admin area, deactivate all plugins temporarily. If the problem disappears, reactivate them one by one to locate the offending plugin.
  • Switch to a default theme (Twenty Twenty‑Four) to rule out theme‑related issues.

White Screen of Death

A blank white screen usually means PHP has encountered a fatal error but error reporting is turned off.

  1. Check the debug.log file created when WP_DEBUG_LOG is enabled. The log will point to the exact file and line causing the problem.
  2. If the log is empty, increase PHP memory limit by adding define( 'WP_MEMORY_LIMIT', '256M' ); to wp-config.php.
  3. Rename the plugins folder via FTP to plugins.disabled. If the site returns, restore the folder name and then rename each plugin folder individually to identify the bad one.
  4. If the problem persists after disabling plugins, switch to a default theme as described earlier.

Internal Server Error (500)

This generic server error often stems from a corrupted .htaccess file, PHP memory exhaustion, or faulty plugins/themes.

  1. Rename .htaccess to .htaccess_old and reload the site. If it works, go to Settings → Permalinks and click Save Changes to regenerate a clean .htaccess.
  2. If renaming .htaccess does not help, increase the PHP memory limit as described for the white screen.
  3. Check server error logs (often found in /logs or via your hosting control panel) for more specific messages.
  4. Disable plugins and switch themes as outlined earlier to isolate the cause.

Error Establishing Database Connection

This message indicates WordPress cannot talk to its MySQL database.

  1. Open wp-config.php and verify the database name, username, password, and host values match those provided by your host.
  2. Test the database connection manually through phpMyAdmin or the mysql command line. If you cannot log in, the credentials are wrong or the database user lacks sufficient privileges.
  3. If the credentials are correct but the error persists, the database server might be down. Contact your hosting provider to confirm MySQL is running.
  4. In rare cases, a corrupted database table can cause the error. Run REPAIR TABLE wp_options; (and other core tables) via phpMyAdmin or use the WP CLI command wp db repair.

404 Errors on Posts or Pages

A 404 when trying to view a specific piece of content usually points to permalink settings or missing rewrite rules.

  1. Visit Settings → Permalinks and simply click Save Changes. This flushes the rewrite rules and often fixes the issue.
  2. If you recently changed your domain or moved the site, update the Site URL and Home URL in Settings → General or directly in wp‑options table.
  3. For multisite installations, ensure the SUBDOMAIN_INSTALL constant matches your configuration.
  4. Check for conflicting plugins that add custom rewrite rules; deactivate them temporarily to test.

Memory Exhausted Fatal Error

The message “Allowed memory size of X bytes exhausted” appears when a script needs more RAM than PHP allows.

  1. Increase the PHP memory limit by adding define( 'WP_MEMORY_LIMIT', '512M' ); to wp-config.php. Some hosts cap the limit; in that case you may need to upgrade your plan.
  2. Identify memory‑heavy plugins. Tools like Query Monitor or the built‑in Site Health screen can show which components consume the most resources.
  3. Consider optimizing images, enabling caching, and using a content delivery network to reduce the load on PHP processes.

Login Page Refresh / Redirect Loop

After entering credentials you are sent back to the login form or stuck in a redirect cycle.

  1. Clear your browser cookies for the site, or try an incognito window.
  2. Check the Site URL and Home URL values; if they point to a different domain than the one you are visiting, WordPress will redirect endlessly.
  3. Rename the plugins folder to disable all plugins. If you can log in afterward, reactivate them one by one to find the culprit.
  4. Inspect your .htaccess for any redirect rules that might interfere with wp‑login.php.
  5. If you recently installed an SSL certificate, ensure the site is configured to force HTTPS correctly; mixed content can cause login loops.

Mixed Content Warnings After Enabling HTTPS

When a site loads over HTTPS but some resources (images, scripts, stylesheets) are still requested via HTTP, browsers block them and show a warning.

  1. Use the Really Simple SSL plugin or run a search‑replace on the database to change http://yourdomain.com to https://yourdomain.com. Tools like Better Search Replace make this safe.
  2. Update hard‑coded URLs in theme files or custom code snippets.
  3. After changes, clear any caching layers (plugin, server, CDN) and test the site with an SSL checker such as SSL Labs.

Plugin or Theme Update Failures

Sometimes an update will abort with a message like “Update failed: Could not copy file.”

  1. Check file permissions. The wp‑content directory and its subfolders should generally be writable by the web server user (often 755 for directories, 644 for files).
  2. Ensure there is enough disk space on the server. A full partition will stop file writes.
  3. Temporarily disable any security plugins that block file modifications, then retry the update.
  4. If the problem persists, perform a manual update via FTP: download the latest version from wordpress.org or the plugin author, delete the old folder, and upload the new one.

Preventive Practices to Reduce Future Errors

While troubleshooting is a necessary skill, a few habits can keep errors from appearing in the first place.

  • Schedule automated backups (daily for active sites, weekly for brochure‑style sites) and store them off‑server.
  • Keep WordPress core, themes, and plugins updated, but test updates on a staging copy before applying them to the live site.
  • Use a reputable hosting provider that offers PHP 8.0+, MySQL 5.7+/MariaDB 10.2+, and sufficient resource limits.
  • Limit the number of active plugins; each additional plugin increases the chance of conflict and adds overhead.
  • Monitor site health regularly via the Tools → Site Health screen; it flags outdated PHP versions, missing extensions, and security issues.
  • Implement a caching solution (such as WP Rocket or Varnish) and a CDN to lower server load and improve response times.

Frequently Asked Questions (FAQs)

What should I do if I cannot access wp‑admin at all?

First, enable WP_DEBUG and check the debug.log file for clues. If you still see a blank screen, rename the plugins folder via FTP to disable all plugins. If that restores access, reactivate plugins one by one. If the admin remains unavailable, switch to a default theme by renaming the current theme’s folder.

My site shows “Error establishing database connection” but the credentials in wp‑config.php are correct. What else could be wrong?

Verify that the MySQL server is actually running. Contact your host or check the server status panel. Also confirm that the database user has the necessary privileges on the database. Occasionally, the database server may be overloaded or experiencing a temporary outage.

After moving my site to a new domain, all internal links lead to 404 pages. How do I fix this?

Update the Site URL and Home URL settings either through Settings → General (if you can access admin) or directly in the wp‑options table. Then run a search‑replace on the database to replace the old domain with the new one. Finally, resave the permalink settings to flush rewrite rules.

Why does my site work fine on HTTP but break after I install an SSL certificate?

The most common cause is mixed content: some files are still loaded via HTTP. Use a plugin like Really Simple SSL or run a database search‑replace to change http://yourdomain.com to https://yourdomain.com. Also check your theme and any custom code for hard‑coded HTTP URLs.

Is it safe to increase the PHP memory limit to 1024M?

Increasing the limit can help with memory‑intensive operations, but you should first confirm that your hosting plan allows such a value. Arbitrarily setting a very high limit may mask underlying problems such as inefficient code or a runaway plugin. It is better to identify the source of high memory usage and optimize it before raising the limit.

How often should I run a database repair?

Only run a repair command when you encounter symptoms like “Error establishing database connection” despite correct credentials, or when the Site Health screen reports corrupted tables. Routine repairs are unnecessary and can add load; regular backups are a safer precaution.

Can a caching plugin cause the white screen of death?

Yes, if a caching plugin writes files to a directory with incorrect permissions or conflicts with another plugin, it can trigger a fatal error that results in a blank screen. Temporarily renaming the caching plugin’s folder is a quick way to test whether it is the source.

Leave a Reply

Your email address will not be published. Required fields are marked *