How to Fix the Error Establishing a Database Connection in WordPress
This error message is clear that your website is unable to connect to the database. Usually this occurs when a user has entered or modified their database credentials (database host, database username, and database password) incorrectly. Sometimes your database server could be unresponsive, or your database may have corrupted. However, most of the time it is usually incorrect database login credentials.
Reason for why it’s happen
- wp-config.php error
- Problems with your hosting provider
- You’ve been hacked! And here I was thinking this particular WordPress error is no big deal.
Database Establishing Error Solutions:
It can also happen due to a configuration on the server. It is also possible that a user would only see white screen of death on certain sections of their site.
Edit your wp-config.php file
Access your wp-config.php file via File Manager or FTP and confirm if the database name, host, username and password are correct.
Fix issues with your web host
If your wp-config.php is looking right and this WordPress error is still a problem, you should talk to your WordPress hosting provider. They will be able to tell you whether the server is down or your database was shut down for exceeding its quota. If they tell you everything looks good on their end, it is time to implement some WordPress security on your site.
Scan your website to determine if it’s compromised.
You can fall victim to a hacker anytime, especially if you don’t know how to secure your WordPress website. To ensure your website hasn’t been hacked, scan it using a tool such as Sucuri Sitecheck.