Casbay Knowledge Base

Search our articles or browse by category below

HOW TO:Fix the “Error Establishing a Database Connection” in WordPress

Last updated: September 8, 2022
Estimated reading time: 1 min

Fix the “Error Establishing a Database Connection” in WordPress

As a dynamic content management system, WordPress relies on a MySQL database that stores your content, website settings, and more. If WordPress is unable to communicate with its database, you’ll see an error message stating: Error establishing a database connection.

Error establishing a database connection message

If your WordPress website was previously working normally, clearly something has changed to break the link between WordPress and the database. Possible causes could be:

  • The database server is down.
  • A change has been made to the database credentials (hostname, username or password) in your wp-config.php file.

If this is the first time you’ve tried to use WordPress, the most likely cause is that your database credentials are incorrect or have changed. Use the following steps to troubleshoot the issue.

Check your WordPress configuration

When installing WordPress, you will have been asked to input a database hostnamedatabase namedatabase username and password. These credentials are stored in your wp-config.php file. A great first step for troubleshooting database connection errors is to check that the database credentials in your wp-config.php file are correct.

You can use an FTP client to access the file on your hosting, or alternatively, use cPanel File Manager.

Firstly, log in to your cPanel.

Secondly, select File Manager.

Then, Navigate to your WordPress folder and look for your wp-config.php file. Right click on the file and select Edit.

Navigate to WordPress folder

You’ll see your database credentials listed under MySQL settings. Check that the database hostnamedatabase namedatabase username, and password are correct. You can find your database credentials at My cPanel > MySQL Databases.

Make any necessary changes in your wp-config.php file and then click Save Changes to proceed. Try to access WordPress once again to see if your issue remains.

Was this article helpful?
Dislike 0
Previous: HOW TO: Change your header in WordPress
Next: Security Tips: WordPress Security Plugin – “Anti-Malware by GOTMLS”
Discover the perfect balance of performance and budget-friendly Dedicated Server plan !
Discover the perfect balance of performance and budget-friendly Dedicated Server plan !
High performance and low cost Dedicated Server plan 128GB from $185 – upgrade today!
High performance and cheap Dedicated Server plan 128GB from $185 – upgrade today!