Fix the ‘Error Establishing Database Connection’ error

The ‘Error Establishing a Database Connection’ error indicates that a website is unable to connect to its database, which results in the website not loading. This error is normally due to incorrect database information in WordPress settings or a corrupted database. Use the steps below to fix the error.

A. Check your database credentials

The most common reason the ‘Error Establishing a Database Connection’ error happens is due to incorrect database credentials in the wp-config.php file – follow the steps below to validate the credentials.

1. Log in to your hosting control panel
2. Click on the File Manager button

3. Double click on the domains folder

4. Locate your website folder and double click on it

5. Double click on the public_html folder

6. Locate the wp-config.php file and right-click on it

7. From the dropdown, select Edit

8. Locate the section called:

/** The name of the database for WordPress */

9. Right under this line, you will find the name of your database. In this example, the name of the database is skystrahelp_wp282

/** The name of the database for WordPress */
define( 'DB_NAME', 'skystrahelp_wp282' );

Here is an example of what the section looks like inside of a wp-config.php file:

10. Now, keep this page open and open a new browser tab and return to your hosting control panel main page
11. From the top right, next to the Domain: field, click on your domain name and select the domain name you want to manage

12. Click on the MySQL databases button

12. Locate your database and click directly on its name

13. Under the Password column, click on Change Password

14. In the password field, generate a new password and/or input your own. If generating one, click the dice ⚁ ⚁ on the left hand side and the system will generate one for you. Then, click on the eye icon to the right 👁️ to reveal it. Note down your password somewhere safe or in your password manager and then click the Save button.

15. Return to your browser tab where the wp-config.php file is open and locate the database password line, for example:

/** Database password */
define( 'DB_PASSWORD', '44p]-S.4o4i6' );

16. Delete the password inside the quotes ‘ ‘ (do not delete the ‘ ‘), put in the new password, then click the Save File button

Here is an example of the process:

17. You’ll also want to make sure that the database user and database name are correct inside of your wp-config.php file at this step
18. Return to your website and reload it

If you are still getting the ‘Error Establishing Database Connection’ error on your website after reviewing the database credentials, this may be due to a database corruption from bad code or incompatibilities – the best solution in this instance is to restore the database from backups using the steps below.

B. Restore database from backups

1. Open this guide: Restore hosting account data from backups
2. Perform a restore for your database