Running a WordPress website is smooth—until an error pops up unexpectedly. Many issues can be resolved quickly with a bit of code tweaking. Here’s a list of common WordPress errors and their fixes.
1. Error Establishing a Database Connection
Issue: Your site shows a message: Error establishing a database connection.
Solution: This usually happens due to incorrect database credentials. To fix it:
// Open wp-config.php and check these lines
define('DB_NAME', 'your_database_name');
define('DB_USER', 'your_database_username');
define('DB_PASSWORD', 'your_database_password');
define('DB_HOST', 'localhost'); // Sometimes this is different, like an IP address
Make sure the credentials match those in your hosting control panel.
2. White Screen of Death
Issue: Your website loads a blank white page with no error messages.
Solution: Enable WordPress debugging to find the error:
// Add this to wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
Check the wp-content/debug.log file for the error message.
3. 500 Internal Server Error
Issue: Your site displays a generic 500 error message.
Solution: This is often caused by a corrupted .htaccess file. Rename it:
// Access your website files and rename .htaccess
mv .htaccess .htaccess_backup
Then, generate a new .htaccess by saving your permalinks again from Settings > Permalinks.
4. Allowed Memory Size Exhausted
Issue: You see an error like: Fatal error: Allowed memory size of X bytes exhausted.
Solution: Increase the memory limit by adding this to wp-config.php:
define('WP_MEMORY_LIMIT', '256M');
If the issue persists, ask your hosting provider to increase the server’s PHP memory limit.
5. Maximum Execution Time Exceeded
Issue: Some operations, like plugin installations, fail due to a timeout.
Solution: Extend the execution time by editing .htaccess:
php_value max_execution_time 300
Alternatively, modify php.ini (if you have access):
max_execution_time = 300;
6. WordPress Not Sending Emails
Issue: Contact form or other emails are not being sent.
Solution: WordPress emails rely on PHP mail, which may not be properly configured. Use SMTP instead:
// Install WP Mail SMTP plugin and configure it with your email provider
add_filter('wp_mail_smtp_options', function($phpmailer) {
$phpmailer->isSMTP();
$phpmailer->Host = 'smtp.your-email.com';
$phpmailer->SMTPAuth = true;
$phpmailer->Username = 'your-email@example.com';
$phpmailer->Password = 'your-email-password';
$phpmailer->SMTPSecure = 'tls';
$phpmailer->Port = 587;
});
Need More Help?
If you’re still facing issues, consider checking error logs or reaching out for expert support. A little debugging goes a long way in keeping your WordPress site running smoothly!