The Error establishing a database connection message in WordPress means your website cannot connect to the MySQL database. When this happens, your site stops loading and shows a blank error page.

This error usually appears after hosting changes, wrong database settings, plugin problems, or server issues. The good news is that you can fix it by checking a few important settings.
What Causes “Error Establishing a Database Connection” in WordPress
WordPress needs four things to connect to the database:
- Database name
- Database username
- Database password
- Database host
If any of these values are wrong, WordPress cannot load your site.
Other common causes include:
- Corrupted database
- Hosting server problem
- Plugin crash
- Database user not assigned
- Wrong DB_HOST value
- Too many server requests
Step 1: Check Database Details in wp-config.php
Most database errors happen because of wrong credentials.
Do this
- Open your hosting panel
- Go to File Manager
- Open your WordPress root folder
- Find the file
wp-config.php- Open the file and check this section
define('DB_NAME', 'database_name');
define('DB_USER', 'database_user');
define('DB_PASSWORD', 'database_password');
define('DB_HOST', 'localhost');Make sure these values match your database in hosting.
Check database info in:
- cPanel → MySQL Databases
- Hostinger → Databases → MySQL
Save the file and reload your site.
Step 2: Check If Database Exists
Sometimes the database gets deleted or renamed.
Check this
- Open hosting panel
- Go to MySQL Databases
- Look for your database name
If the database is missing, restore backup from hosting.
Step 3: Repair Corrupted Database
If database tables break, WordPress cannot connect.
Enable repair mode
Open wp-config.php and add:
define('WP_ALLOW_REPAIR', true);Now open:
yourdomain.com/wp-admin/maint/repair.phpClick:
Repair DatabaseAfter repair, remove the line from wp-config.php.
Step 4: Check Database User Permissions
Sometimes the database user does not have permission.
Fix
- Open cPanel
- Go to MySQL Databases
- Scroll to Add User to Database
- Select user and database
- Click Add
- Select ALL PRIVILEGES
- Save
Reload your site.
Step 5: Check DB_HOST Value
Some hosts do not use localhost.
Try changing DB_HOST in wp-config.php.
localhost
127.0.0.1
mysql.hostinger.com
db.hostinger.comCheck the correct host in your hosting database page.
Step 6: Disable Plugins (If Error Started After Update)
Plugin crashes can stop database connection.
Fix
- Open File Manager
- Go to
/wp-content/- Rename folder
plugins → plugins_oldReload site.
If site works, plugin caused the error.
Rename back and disable plugins one by one.
Step 7: Check Hosting Server Status
Sometimes the problem is not your site.
Database server may be down.
Check:
- Hosting status page
- MySQL service
- Resource limits
- CPU / RAM usage
Contact hosting support if needed.
Step 8: Check for High Traffic or Resource Limit
On shared hosting, too many requests can stop database.
Fix:
- Enable cache plugin
- Use Cloudflare
- Remove heavy plugins
- Upgrade hosting plan
The Error establishing a database connection looks serious, but most cases happen because of wrong database settings or server issues.
Always check:
- wp-config.php credentials
- Database exists
- User permissions
- DB_HOST value
- Plugins
- Hosting status
Fixing these usually restores your WordPress site in minutes.