How to Fix WordPress “Error Establishing a Database Connection”

How to Fix WordPress “Error Establishing a Database Connection”

This error means WordPress can’t connect to your database. The issue usually comes from incorrect login credentials, corrupted database files, or a crashed MySQL server.

Start by checking the wp-config.php file. Verify your database name, username, password, and host. Even a small typo can cause the error. If credentials are correct, log into phpMyAdmin to check whether your database is accessible.

If you suspect corruption, select your database and run “Repair Database.” You can also enable auto-repair by adding this line in wp-config.php:

				
					define('WP_ALLOW_REPAIR', true);

				
			
This will display the error causing the issue. Next, check your plugins by disabling them all via FTP or File Manager. If the site loads again, reactivate plugins one by one to identify the faulty one. If plugins aren’t the problem, switch to a default WordPress theme like Twenty Twenty-Four. If the site loads, the issue lies in your theme. Another common fix is increasing the PHP memory limit. Add this line in wp-config.php:

Do you need an expert? HIRE US NOW!