Error Establishing a Database Connection: How to Fix It

Last Updated: 23 Nov, 2026

The “Error establishing a database connection” message means WordPress cannot talk to its database. The most common cause is wrong credentials in wp-config.php. Open that file, compare DB_NAME, DB_USER and DB_PASSWORD with the details in your hosting panel, correct any mismatch, and if all is right, wait a few minutes in case the server is down.

What does “Error establishing a database connection” mean?

This is the most common WordPress error. It means the WordPress files cannot talk to the database.

Picture the website as a restaurant. The WordPress files are the waiters and the database is the kitchen where all the orders, recipes and stock are kept. When the waiters cannot reach the kitchen, nothing is served, and your visitor sees a plain white page with that sentence.

Why does this error happen?

The usual cause is incorrect credentials in the configuration file. Other causes include a temporary server problem, a deleted or damaged database, or a recent move to a new host or domain.

What you changed or saw Likely cause
Just installed WordPress Typo in database name, username or password
Just moved to a new host Old credentials still in wp-config.php
Site worked yesterday, nothing changed Temporary server issue or database overload
Error only on /wp-admin Damaged database tables
Changed the database password in the panel wp-config.php still has the old password

How to fix the error step by step

Work through these in order. Stop as soon as the site comes back.

Step 1: Open wp-config.php

Go to your hosting dashboard, open File Manager, then public_html, and open wp-config.php. Before editing, download a copy so you can undo your changes.

Step 2: Check the three key lines

Look for DB_NAME (database name), DB_USER (database username) and DB_PASSWORD (database password).

Step 3: Cross-check with the hosting panel

Compare those values with the details in your hosting panel’s MySQL Databases section. They must match exactly, including capital letters and special characters. Copy and paste instead of retyping.

If you do not remember the password, reset it in the panel, then paste the new one into wp-config.php. The two places must always agree.

Step 4: Check the database host

Most hosts use localhost as the database host, but some give a different address. If your host’s documentation shows a different value, update DB_HOST in wp-config.php.

Step 5: Confirm the database still exists

Open phpMyAdmin from your hosting panel and look for your database in the left list. If it is missing or empty, restore it from a backup.

Step 6: Wait if everything is correct

If the information is 100 percent correct and it still fails, it may be a temporary server error. Wait 5 to 10 minutes before making further changes.

Changing settings repeatedly while the server recovers makes it harder to know what fixed the problem.

Flow of six fixes for the error establishing a database connection, in order
Fixing the database connection error, step by step

Error only on the dashboard? Try repairing the database

Sometimes the front of the site loads but the admin area shows a message about database tables. WordPress has a built-in repair tool you can switch on by adding one line to wp-config.php, using the setting called WP_ALLOW_REPAIR. Follow the current instructions in the official WordPress documentation, run the repair once, then remove the line, because the repair page does not require a login while it is on.

How to tell a credentials problem from a server outage

Two quick checks save time. First, open phpMyAdmin from your hosting panel. If it opens and shows your database, the database is alive and the credentials in wp-config.php are the likely culprit. Second, check whether other sites or tools on the same hosting account are also failing, and look at your host’s status page. If everything on the account is down, the problem is on the server side and waiting or contacting support is the right move.

What to tell your host if nothing works

Contact support and give them three facts: when the error began, what you changed last and the database name. Ask them to check whether the database service is running and whether your account has hit a resource limit. A good host can tell you in minutes.

How to avoid this error next time

  • Save the database name, username and password in a password manager when you create them.
  • Take a backup before editing wp-config.php or moving the site.
  • After any migration, update wp-config.php straight away.
  • Do not rename or delete databases in the panel unless you are sure which site uses them.

A quick troubleshooting card

Wrong credentials is the cause in most cases, so check wp-config.php first. If that is fine, wait ten minutes. If the dashboard alone fails, use the repair tool. If the database is missing, restore a backup. If you are still stuck, contact your host with the three facts above.

Frequently Asked Questions

Will I lose my website content because of this error?

Usually not. Your posts and pages live in the database, which is normally untouched. The error only means WordPress cannot reach it. Do not delete anything until you know why.

Why did this appear right after I moved my site?

The new host uses a different database name, username or password. Update the three values in wp-config.php to match the new panel.

Does a plugin cause this error?

Rarely. A plugin can overload the database and trigger it, but credentials and server problems are far more common.

How can I tell if it is my host's problem?

If your credentials are correct and other sites on the same host also fail, the server is the likely cause. Check the host’s status page or ask support.

Can I fix it without editing files?

If the credentials are wrong, you must update wp-config.php. If the host is the problem, there is nothing for you to edit.

How long should I wait before contacting support?

Give it 10 minutes, then contact them. Include the time the error began.