Your cart is currently empty!
How to Diagnose and Repair WordPress Errors – The Debug‑Mode Playbook
“When a site goes down, you first turn the lights on.” – WordPress Wisdom
If you’re running a WordPress site, you’ve probably hit at least one error in your life. Whether it’s a “White‑Screen‑of‑Death,” a 500 Internal Server Error, or a cryptic “Fatal error: Call to undefined function”, those messages can feel like a mystery. The good news? WordPress gives you a powerful built‑in toolset to turn that mystery into a solvable puzzle – Debug Mode and PHP error tracking.
In this article we’ll walk through:
- What common WordPress errors look like
- How to enable and use debug mode safely
- Reading PHP error logs and interpreting the clues
- Step‑by‑step troubleshooting tips
- Why a production‑ready error tracking system matters
Let’s get your site back to life!
1. WordPress Errors – The “What” and “Why”
| Type of Error | Typical Symptoms | Likely Cause |
|---|---|---|
| Fatal PHP errors | Entire page crashes, “White‑Screen‑of‑Death” | Syntax errors, missing functions, plugin/theme conflicts |
| Warning / Notice | “Deprecated” warnings, “undefined index” | Out‑of‑date code, legacy plugins |
| Database errors | “Error establishing a database connection” | Wrong credentials, corrupted tables |
| Server errors (500) | Blank page with a generic error | PHP memory limit, .htaccess mis‑configuration |
| 404 / 500 on uploads | Images, CSS, or JS files missing | File permissions, .htaccess rules |
| Security‑related | “The session has expired” | Session timeout, cookie issue |
Every error has a root cause. The trick is to see the root cause, not just the symptom. That’s where debug mode shines.
2. Turn on Debug Mode (Your Diagnostic Headlights)
WordPress’s wp-config.php file has a few constants that control debugging. The most common trio:
// Enable all debugging
define( ‘WP_DEBUG’, true ); // Show errors
// Log errors to wp-content/debug.log
define( ‘WP_DEBUG_LOG’, true ); // Write to a file
// Show errors in the browser (useful on a staging site)
define( ‘WP_DEBUG_DISPLAY’, false ); // Set to true in dev, false in prod
How to Add It
- Open
wp-config.phpvia FTP, SFTP, or the File Editor in cPanel. - Locate the line that says
/* That's all, stop editing! Happy blogging. */. - Insert the three constants just above that line.
- Save and re‑upload if needed.
Tip: Use a staging environment. Enabling
WP_DEBUG_DISPLAYon a live site can expose sensitive data to visitors.
What Happens Next?
- Fatal errors: WordPress will output a stack trace in the browser (if
WP_DEBUG_DISPLAYis true) or log it. - Warnings/Notices: These will also be logged.
- All errors: Go to
wp-content/debug.logfor a consolidated view.
3. Reading the Log – Turning Stack Traces into Clues
A typical fatal error in the log looks like this:
[09:13:42 UTC] PHP Fatal error: Uncaught Error: Call to undefined function my_plugin_init() in /home/user/public_html/wp-content/plugins/my-plugin/my-plugin.php:12
Key components to spot:
| Element | Meaning |
|---|---|
| Timestamp | When the error happened |
| Error type | Fatal, Warning, Notice |
| Error message | What failed |
| File path & line | Where to look |
| Stack trace | Call order – can hint at the cause |
Common patterns:
| Error | Likely Fix |
|---|---|
Call to undefined function | Missing or corrupted plugin file, wrong PHP version |
Allowed memory size exhausted | Increase WP_MEMORY_LIMIT or PHP memory in php.ini |
mysqli_sql_exception: Table … does not exist | Database corruption, missing tables |
Permission denied | File/folder permissions (usually 644/755) |
4. Step‑by‑Step Troubleshooting
Below is a practical workflow you can follow when an error appears.
4.1. Replicate Locally (Optional but Powerful)
If you can, clone your site to a local environment (MAMP, XAMPP, Local by Flywheel). Then replicate the issue in a sandbox—no risk to live traffic.
4.2. Check the Basics
| Check | How |
|---|---|
| WordPress core files | wp core verify-checksums |
| Plugin list | Deactivate all, then reactivate one by one |
| Theme | Switch to Twenty Twenty‑Three |
| PHP version | php -v or check your host’s PHP info |
| File permissions | 644 for files, 755 for folders |
4.3. Disable All Plugins
- Rename the
wp-content/pluginsfolder toplugins-old. - Check if the error disappears.
- If it’s gone: The culprit is a plugin. Reactivate them one by one until the error re‑appears.
4.4. Switch to Default Theme
Rename the active theme folder in wp-content/themes. WordPress falls back to a default theme. If the error disappears, the theme is at fault.
4.5. Increase PHP Memory
Add to wp-config.php:
define( ‘WP_MEMORY_LIMIT’, ‘256M’ ); // 256 MB
If you still see Allowed memory size exhausted, check php.ini or ask your host.
4.6. Look at the Database
- Use phpMyAdmin or Adminer to run
SHOW TABLES;. - Check for missing tables or corrupted indexes.
- Run WordPress repair: add
define( 'WP_ALLOW_REPAIR', true );and visithttp://yoursite.com/wp-admin/maint/repair.php.
4.7. Consult .htaccess
If you have custom rewrite rules, comment them out temporarily and see if the error resolves. Use the default WordPress .htaccess
5. Going Beyond: External Error Tracking
When your site gets bigger, you might need a more sophisticated error reporting system. Several services let you capture, aggregate, and alert on PHP errors:
| Service | Key Features | How to Hook into WordPress |
|---|---|---|
| Sentry | Real‑time alerts, stack traces, user context | Use the “Sentry for PHP” SDK + WP plugin |
| New Relic | Performance monitoring + error traces | Install New Relic agent on your host |
| WP‑Error‑Tracker | Simple log viewer with notifications | Install via Plugins → Add New |
| Errorception | Advanced error handling with custom actions | Add to functions.php |
Why use them?
- Visibility: Errors that slip past your local logs are caught in production.
- Prioritization: Get alerts only for critical errors.
- Root cause analysis: Stack traces with line numbers, function calls, and context.
6. Production‑Ready Debugging: A Best‑Practice Checklist
| Item | Why | How |
|---|---|---|
WP_DEBUG OFF | Prevents sensitive data leakage | Keep it false on live sites |
WP_DEBUG_LOG ON | Keeps a record | Log to wp-content/debug.log |
WP_DEBUG_DISPLAY OFF | Hide errors from visitors | Set to false in production |
| Log rotation | Avoid huge log files | Use server cron or a plugin |
| File permissions | Protect log files | 640 for logs, readable only by server |
| Backup before changes | Safeguard data | Use a backup plugin or hosting snapshot |
| Use a staging environment | Test fixes safely | Local or sub‑domain with same config |
7. Quick Reference – The “One‑Line” Debug Commands
| Purpose | Code |
|---|---|
| Enable all debugging | define( 'WP_DEBUG', true ); |
| Log only | define( 'WP_DEBUG_DISPLAY', false ); |
| Increase memory | define( 'WP_MEMORY_LIMIT', '256M' ); |
| Allow repair | define( 'WP_ALLOW_REPAIR', true ); |
| Set custom error handler | set_error_handler( 'my_error_handler' ); |
8. FAQ
| Question | Answer |
|---|---|
Can I enable WP_DEBUG on my live site? | It’s safe if you keep WP_DEBUG_DISPLAY false and log to a file. Never show errors to end‑users. |
| What if my error says “Undefined index: $_POST”? | You’re trying to read a POST variable that doesn’t exist. Use isset() before accessing. |
| Why does my site keep 500 errors after a plugin update? | The plugin may have removed a required file. Deactivate the plugin and try again. |
How do I increase PHP memory if I don’t control php.ini? | Add define( 'WP_MEMORY_LIMIT', '256M' ); in wp-config.php or contact your host. |
9. Take‑away
- Enable debug mode to see exactly what’s going wrong.
- Read the logs carefully – they’re the map to your error.
- Use a systematic approach: plugins → theme → memory → database.
- Keep the live site clean: disable debug display, log to a file, rotate logs.
- Add an external error tracker for larger sites or shared hosting.
Once you get the hang of turning the lights on with WP_DEBUG, every WordPress error becomes a solvable puzzle rather than a mystery.
This article was written by Calabastro, a multi modal AI.

