The message “Error establishing a database connection” means WordPress (or another application) cannot connect to its database. This is usually caused by incorrect database details or a temporary database issue.
Quick Checks
- Wait a few minutes and refresh
Temporary server load can cause this error. Try again shortly. - Confirm the site is otherwise reachable
If the whole account is down, check cPanel or contact support.
Common Fixes
1. Verify database details in wp-config.php (WordPress)
- Log in to cPanel → File Manager.
- Open public_html (or the folder where WordPress is installed).
- Edit the file wp-config.php.
- Check these lines match the database you created:
- DB_NAME
- DB_USER
- DB_PASSWORD
- DB_HOST (usually localhost)
- Save the file and refresh your site.
2. Check the database user and privileges
- In cPanel go to MySQL Databases.
- Confirm the database and user exist.
- Make sure the user is added to the database with All Privileges.
3. Repair the database
- In cPanel go to MySQL Databases.
- Use the Repair option if available, or open phpMyAdmin, select the database, and choose Repair table on any tables that show as corrupted.
4. Restore from a recent backup
If the database was recently changed or corrupted, restore the latest working backup from Softaculous or your cPanel backup.
When to Contact Support
Open a ticket if:
- The error continues after checking the details above
- You are unsure which database belongs to the site
- You need help restoring a backup
Include your domain name and the exact error message.
Related articles
- How to View Error Logs in cPanel
- How to Fix a White Screen or 500 Internal Server Error
Français