Guides › WordPress › Site down or error screens

WordPress "Error Establishing a Database Connection": Causes and Fixes

WordPress cannot reach its database. The most common cause is a wrong value in wp-config.php, and it is fixable in minutes.

Tested by SiteFixLab. We tested a wrong database name on a real Hostinger test site and fixed it. The other causes below were not reproduced by us.
Site down or error page

This error means WordPress could not log in to its database. Something in the connection details is wrong, or the database server is not answering.

public_html (site root)wp-config.php ← database details live herewp-content (plugins, themes, uploads)wp-adminwp-includes.htaccess (hidden file)
Where wp-config.php sits: in the site's root folder, next to wp-content.

Cause 1: A wrong value in wp-config.php

Illustration for Cause 1: A wrong value in wp-config.php

Open wp-config.php and check these four lines against your hosting panel (Databases section):

define( 'DB_NAME', 'your_database_name' );
define( 'DB_USER', 'your_database_user' );
define( 'DB_PASSWORD', 'your_database_password' );
define( 'DB_HOST', 'localhost' );

Compare the database name letter by letter. A single extra or missing character gives this error. Look for a hidden space inside the quotes, too.

Cause 2: Wrong password

Illustration for Cause 2: Wrong password

If you changed the database user's password in the panel, put the same password in DB_PASSWORD. If you are not sure of the current one, set a new one in the panel and copy it into the file.

Cause 3: Wrong host

Illustration for Cause 3: Wrong host

Most hosts use localhost, but some use 127.0.0.1 or a special address. Your host's help pages say which.

Cause 4: The database server is down or overloaded

Illustration for Cause 4: The database server is down or overloaded

If the details are right and the site fails only at times, the server may be busy. Check your host's status page, or contact support.

Cause 5: Damaged tables

Illustration for Cause 5: Damaged tables

Add this line to wp-config.php, then open yoursite.com/wp-admin/maint/repair.php:

define( 'WP_ALLOW_REPAIR', true );

Remove the line when you are done. The repair page can be used without logging in, so do not leave it enabled.

Cause 6: Wrong table prefix or missing tables

Illustration for Cause 6: Wrong table prefix or missing tables

The $table_prefix in wp-config.php must match the prefix of the tables in your database.

Self-repair tool

Our upcoming Database Checker and Auto-Fix tools test these values for you.

Free checker tool

Not sure which value is wrong? Our free read-only Database Checker tests your database login and tells you which value to fix. It changes nothing.

Free tool for this problem: Database Checker

Related guides

Did this solve it? If not, email hello@sitefixlab.org with the exact error text and we will look into it. Try the problem finder.

Last updated 2026-11-21.