Error Establishing a Database Connection

When you see the above message, the problem is clear: WordPress can not connect to the site’s database.

In case you didn’t know, the database is where WordPress saves all your content, like posts and pages and other vital information.

It is an essential part of the website that your site can not exist without. Consequently, when the connection is down, so is your site.


Most times, this common WordPress error is caused by faulty credentials inside wp-config.php. However, there are other possible culprits and solutions.

1. Check wp-config.php

This file holds all the login info for the database that you entered at installation (database name, username, password and server).

It can be found in the root directory of your WordPress installation.

If there is a problem with your site connecting to the database (especially if you have made any changes to the above information), check the credentials here to see if they line up.

2. Access wp-admin

Sometimes things go wrong with the database which cause the need for WordPress to fix it.

In those cases, when you go to, you will see a different kind of error message stating that your database needs to be repaired.

If that is the case, add the following line to wp-config.php to enable this feature:
define('WP_ALLOW_REPAIR', true);
After that, access to start the process. When you are done, be sure to remove the line from wp-config.php again as other people will be able to access this function otherwise.

3. Talk to your host

Again, the problem can also lie on the provider’s side.

If neither of the solutions above are working, there might be something wrong with the MySQL server or you might have reached the maximum size of your database.

In both cases your hosting provider needs to be part of the solution.