How to Diagnose Website Errors (500/404/403 Errors)


1. How to Diagnose Website Errors (500/404/403 Errors)

500 Internal Server Error

What’s happening? The server encountered an unexpected issue (e.g., code errors, plugin conflicts).

How to Fix:

  1. Check Server Logs
    • For Apache: Open terminal and run:
      tail -n 20 /var/log/apache2/error.log
    • For Nginx: Open terminal and run:
      tail -n 20 /var/log/nginx/error.log
  2. Fix PHP Syntax Errors

    Example broken code:

    Fixed code:

  3. Increase PHP Memory Limit

    Add to wp-config.php:

    define('WP_MEMORY_LIMIT', '256M');

404 Not Found Error

What’s happening? The page/resource you’re trying to access doesn’t exist.

How to Fix:

  1. Redirect Broken Links

    Add to .htaccess:

    Redirect 301 /old-page /new-page
  2. Create a Custom 404 Page
    
    

403 Forbidden Error

What’s happening? Access denied (e.g., incorrect file permissions).

How to Fix:

  1. Fix File Permissions
    chmod 644 filename.php  // For files
    chmod 755 directory/    // For folders
  2. Disable Directory Listing

    Add to .htaccess:

    Options -Indexes

2. Steps to Debug "White Screen of Death" (WSOD)

How to Fix:

  1. Enable Debugging

    Add to wp-config.php:

    define('WP_DEBUG', true);
    define('WP_DEBUG_LOG', true);
  2. Increase PHP Memory Limit
    define('WP_MEMORY_LIMIT', '256M');
  3. Disable Plugins/Themes

    Rename the plugins folder via FTP (e.g., plugins_deactivated).

3. Resolving Slow Website Performance

Server-Side Fixes

  1. Enable Caching
    
      ExpiresActive On
      ExpiresByType image/jpg "access 1 year"
      ExpiresByType text/css "access 1 month"
    

Client-Side Fixes

  1. Optimize Images

    Use TinyPNG to compress images.

4. Fixing Broken Links

How to Fix:

  1. Redirect Broken Links
    Redirect 301 /broken-link https://example.com/new-link

5. Browser Developer Tools

How to Use:

  1. Open DevTools

    Windows: F12 or Ctrl + Shift + I
    Mac: Cmd + Option + I

  2. Debug JavaScript Errors

    Go to the Console tab to view errors.

Note: Replace placeholder URLs (e.g., /old-page) with your actual URLs. Test changes in a staging environment first.

Did you find this article useful?