The “Error establishing a database connection” message in WordPress means that the website cannot connect to its database. In most cases, this happens due to incorrect database access details in the WordPress configuration file:

In this guide, we’ll cover the most common causes of this error and guide you through the steps to fix it.
In most cases, the "Error establishing a database connection" error occurs when WordPress is using incorrect database access details. This often happens after:
Migrating a website to a new hosting provider
Changing database passwords
Restoring a backup
Manually editing configuration files
Moving files between servers or hosting plans
WordPress connects to its database using a database name, a database username, a password, a database host, and the access privileges assigned to the database user.
Thus, it’s needed to make sure all of the following conditions are met:
The database name exists on the server and matches the existing database name
The database username matches the existing database user
The password is correct for that user
The database user is assigned to the database
The user has full access privileges (ALL PRIVILEGES)
All database connection details are stored in the wp-config.php file, located in the root directory of your WordPress installation. To check and verify them, do the following:
Log in to your cPanel and go to File Manager:

Navigate to your WordPress root directory and open the wp-config.php file (via Edit or View options):

Note: When choosing Edit, you may want to create a backup of your wp-config.php file:

Look for these lines that contain the database name, user, and password:

In another tab, open the Manage My Databases menu:

Attentively check if the database name and user match the ones specified in wp-config.php:

Scroll down and ensure that the database user indeed exists on the server:

There is no possibility to see what password is set for a database user, so it is necessary to set it by clicking Change Password:


Update the values in wp-config.php if needed.
Ensure the correct database user is assigned to the database and has All Privileges enabled (click on the user >> checkmark All Privileges >> Make Changes):


Refresh your website! If the credentials are correct, the website should load normally.
If the database credentials are correct and the error is still present, the issue may be caused by:
A corrupted database
A temporary MySQL server outage
Damaged WordPress core files
At this stage, please contact our Support Team so that we can check the database service status and logs.