Debugging a WordPress site: A complete guide to troubleshooting errors and problems

A WordPress site that crashes can quickly become a headache. PHP errors, white screens, database problems… there are a multitude of causes that can affect the smooth running of your site. This guide will help you diagnose and solve these problems by following a structured approach and using the best tools and techniques available. Consult the official WordPress debugging documentation in addition to this article.

1. Common WordPress errors and their causes

1.1 Fatal errors and PHP errors

PHP errors are often caused by a plugin, a poorly coded theme or a lack of allocated memory. They can be displayed in debug mode. These errors prevent the site from functioning properly and can be located using error logs.

1.2. The white screen of death (WSOD)

A critical problem that prevents WordPress from running correctly, is often caused by a fatal PHP error or a faulty plugin/theme. We recommend activating debug mode to identify the source of the problem and test the site by disabling extensions.

1.3 Database connection error

This message indicates that WordPress cannot access the database, either due to an error in wp-config.php or a MySQL failure. Check the login details, repair the database via phpMyAdmin and contact the hosting provider if necessary.

1.4 Error 500 – Internal Server Error

A generic server error due to a corrupted .htaccess file, or a problematic plugin or theme. Check the error logs, test by disabling extensions and resetting .htaccess.

1.5. Error 403 – Access forbidden (Forbidden)

Often caused by incorrect file permissions or overly strict security rules. Make sure files and folders have the correct permissions (644 for files, 755 for folders).

1.6 Error 503 – Service temporarily unavailable

The problem is due to server overload or extension consuming too many resources. Test by deactivating plugins, and check the status of server resources with your web host.

1.7 “Too many redirects” error

This can occur if the site URL is misconfigured or if conflicting redirects are in place. Check permalink settings and temporarily disable redirect plugins.

1.8. Allowed memory size exhausted” error

WordPress reaches the PHP memory limit, which can be corrected by increasing the value in wp-config.php and optimizing heavy scripts.

1.9. Other HTTP errors (502 Bad Gateway, 504 Gateway Timeout, etc.)

These errors are often due to a server problem or queries that are too long. Check whether your server is overloaded and optimize SQL queries.

2. Essential tools for debugging a WordPress site

2.1. Enable WordPress to debug mode (WP_DEBUG)

Add this line to wp-config.php :

  • define(‘WP_DEBUG’, true);
  • define(‘WP_DEBUG_LOG’, true);
  • define(‘WP_DEBUG_DISPLAY’, false);

Errors will be logged in wp-content/debug.log.

2.2. Diagnostic and debugging plugins

  • Query Monitor: Analyzes SQL queries and PHP errors.
  • Debug Bar: Displays HTTP errors and requests.
  • Health Check & Troubleshooting: Temporarily disable plugins to identify conflicts.

2.3. Using the browser console

Inspect for JavaScript and CSS errors via the browser’s development tools (F12).

2.4. Access server logs

View PHP error logs via cPanel or FTP.

2.5. External tools for analyzing performance

  • GTmetrix and Google PageSpeed Insights to measure loading times.
  • New Relic for profiling PHP script execution.

3. Steps for diagnosing and resolving WordPress problems

3.1. Deactivating plug-ins

Rename the wp-content/plugins folder to plugins_old to deactivate all plugins.

3.2. Testing with a default theme

Activate a default WordPress theme to see if the problem is with the theme.

3.3. Checking and regenerating the .htaccess file

Rename .htaccess and save the permalinks in WordPress to recreate a new one.

3.4. Increasing PHP memory

Add this line to wp-config.php :

  • define(‘WP_MEMORY_LIMIT’, ‘256M’);

3.5. Repair and optimize the database

Add define(‘WP_ALLOW_REPAIR’, true); in wp-config.php and access wp-admin/maint/repair.php.

3.6. Reinstalling WordPress files

Download the latest version of WordPress and replace all files except wp-content.

3.7. Contact the host

If the problem persists, request access to the logs and check the server status.

4. Solving performance and compatibility problems

4.1. Improve site speed

  • Activate a cache plugin(WP Rocket, W3 Total Cache or LiteSpeed).
  • Optimize images with Imagify, SMUSH or ShortPixel.
  • Activate a CDN to serve static resources faster.

4.2 Resolving conflicts between plugins and themes

Test by deactivating plugins one by one.

4.3. Check compatibility of updates

Check that your version of WordPress and PHP is compatible with the installed plugins.

5. Best practices to avoid mistakes in the future

5.1. Keeping WordPress and its extensions up to date

Update regularly to avoid vulnerabilities.

5.2. Make regular backups

Use UpdraftPlus or BackupBuddy to automate backups.

5.3. Limiting the number of plugins

Keep only essential extensions.

5.4. Test on a staging site before updating

Avoid updating directly in production.

By following these steps, you’ll be able to diagnose and correct most WordPress problems. Apply best practices to minimize future risks and ensure the stability of your site!

Scroll to Top