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

Last modified: April 2, 2020
You are here:
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.

wordpress-Error message
Error establishing a database connection


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.

wordpress-wp folder-wp-config.php file
Find wp-config.php file and edit


You’ll see your database credentials listed under MySQL settings. Check that the database hostnamedatabase namedatabase usernameand 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
Views: 44
Customer Services Contact

Need Help? Send a Ticket to our 24X7 Technical Support Team

Subscribe Newsletter

Subscribe to Casbay Newsletter for online tips, events and latest promotion !

Copyright © 2010 – 2021 Casbay Sdn. Bhd. (1042688-D). All Rights Reserved.

All Trademarks Are The Property of Their Respective Owner.