Article overview

Help article

Fixing 'Error Establishing a Database Connection' in WordPress

It's possible the error message 'Error Establishing a Database Connection' is shown when visiting your WordPress website.

Although this error message may seem severe, it is actually fairly easy to solve. Essentially, it means your website is unable to connect to the database assigned to it.

This article tells you more about the cause of 'Error Establishing a Database Connection' and, most importantly, how to solve this error message.

Edit your database password

As we've mentioned, you are seeing this error because your WordPress website is unable to establish a database connection.

Your WordPress website contains a configuration file (wp-config.php) in which the login credentials of your database are stored. Your WordPress website uses these credentials to connect to the website's database.

If the database login credentials within wp-config.php do not match the actual credentials of your database, you will see 'Error establishing a database connection' when visiting your WordPress website. This happens when you've changed the database password in your control panel without changing the database password in your wp-config.php file.

To solve this, you can simply use the database password within wp-config.php as the actual password of your database.

Step 1

Log on to your control panel and head over to the tab 'Domains & Hosting'. Next, select your domain name on the left hand side (don't check the box).

Now click on the cog wheel next to 'Your website', followed by 'SFTP filemanagement'.

Click on sftp filemanagement

See the article 'Using SFTP filemanagement in your control panel' for a guide on using SFTP filemanagement.

Step 2

Open the 'www' folder and select the wp-config.php file. Click on 'Open' on the right hand side to view the contents of the wp-config.php file.

Open the wp-config.php file

Step 3

You can find the database password inside the wp-config.php file. Scroll down to the line shown below:

/** MySQL database password */
define('DB_PASSWORD', 'ExamplePassword123');

This is the line that tells your website what the password of your database should be (in our example the password is ExamplePassword123). Write down the password from your wp-config.php file and follow the steps below.

Step 4

Now you've written down the password used by your wp-config.php file, it's time to set this password as your actual database password.

Also see 'Creating and managing a database' for more information on using databases.

Visit your control panel and head to the tab 'Domains & Hosting' again. Select your domain name on the left hand side and click on the cog wheel next to 'Your website'. This time, click on 'Database'.

Click on database

Step 5

Click on the database name of your WordPress website.

Click on your database name

Step 6

Now enter the password you wrote down earlier and click on 'Save'. The database connection should now be re-established and your website should be visible once more.

enter the database password from wp-config.php

Check the other credentials in the wp-config.php file

If you're still getting the 'Error Establishing a Database Connection' message after following the steps in 'Edit your database password', the other database credentials in wp-config.php may be the cause.

To check this, head over to 'Domains & Hosting' in your control panel and select your domain name again. Click on the cog wheel next to 'Your website' and click on 'Database'. The image below shows an example of what your database overview looks like.

your database overview

Keep this page open and go back to 'Domains & Hosting' in your control panel. Click the cog wheel next to 'Your website and click on 'SFTP filemanagement'.

Open the 'www' folder, select the wp-config.php file and click 'Open' on the right hand side. The wp-config.php file will now be opened in a new browser tab.

Search your wp-config.php file for the following lines and check if the database login credentials are correct.

  • Does DB_HOST have 'localhost' next to it?
  • Does DB_USER show the same username as your database overview?
  • Does DB_NAME show the same database name as your database overview?

If the information in your wp-config.php file does not match the information on the 'Manage your database' overview in your control panel, you will need to edit the wp-config.php file.

You do this by navigating to 'SFTP filemanagement' and selecting the wp-config.php file in the www folder again. This time, click on 'Download' and edit the file with a 'plain text editor', such as Notepad++ for Windows and SublimeText for macOS.

Don't open the wp-config.php file in advanced text editors, such as Microsoft Word. These editors add hidden markup, which renders the wp-config.php file unusable. 

Edit the information in the wp-config.php file (DB_HOSTDB_USER DB_NAME) so they match the information in your database overview. Save the wp-config.php file and replace it with the current wp-config.php file in SFTP filemanagement by dragging it onto the file. Your website will now be able to connect to your database again.


your database overview

The image above shows an example of your database information in your control panel.

The image below shows what the lines in your wp-config.php should look like based on the information of your database.

example of wp-config.php

In this article we explained how to fix the 'Error establishing a database connection' message.

If your website is still showing the message after following the steps in this article or if you have any other questions regarding this article, don't hesitate to contact our support team.

You can reach them using the 'Contact us' button below or via the 'Contact' button inside your control panel.

If you wish to discuss this article with other users, feel free to leave a comment below.

Has this article been helpful?

Create an account or log in to leave a rating.


Create an account or log in to be able to leave a comment.