Skip to content
Fix Library

Error establishing a database connection: fix

WordPress says 'Error establishing a database connection'? See the causes, check wp-config.php safely, repair tables and know when to call. (804) 375-4450

At a glance

The WordPress message Error establishing a database connection means the site could not reach its MySQL or MariaDB database. Usual causes are wrong credentials in wp-config.php, a database server that is down or overloaded, or damaged tables. Your content is normally still there. This guide shows safe checks, repair steps and when to call.

Updated November 29, 2026

  • For owners whose site shows the database connection error
  • Usual causes wrong credentials, host outage, damaged tables, full disk
  • Safe first step back up files, export the database if possible
  • Data normally still intact; the site cannot reach it
  • Emergency response 15 minutes with emergency credits; rescue is pay-only-if-fixed
  • Start call the help desk or post a project

"Error establishing a database connection" means WordPress could not talk to its MySQL or MariaDB database. The usual causes are wrong credentials in wp-config.php, a database server that is down or full, or damaged tables. Your content is normally still there.

What this error means

WordPress stores all posts, pages, users and settings in a database. On every request it connects using four values from wp-config.php. If that connection fails, WordPress cannot load anything, so it shows this single message.

Common causes

CauseTypical clueWho can fix it
Database server down or overloadedError comes and goes, often at busy timesHost
Changed credentialsAppeared after a migration or password resetYou
Wrong DB_HOSTSome hosts need a hostname other than localhostYou
Corrupted tablesWp-admin offers to repair the databaseYou, with a backup
User lost permissions, or database deletedLogin fails in phpMyAdmin tooHost
Disk or quota fullHosting panel shows 100 percent usageYou or host

Safe steps to try

Back up the site files first, and export the database if your host allows it.

  1. Check whether the host has an outage

    Look at your host's status page, and check whether other sites on the same account fail too.

  2. Test wp-admin

    Visit /wp-admin. A different message, such as a request to repair the database, narrows the cause.

  3. Compare credentials

    Open wp-config.php and read these four lines:

15:00
Credentials, host, then tables: check them in that order

How to tell which cause you have

Open /wp-admin and compare it with the front end. If wp-admin shows a different message about repairing the database, the connection works and a table needs repair. If both show the same connection error, the credentials, the host name or the server are at fault. If the error appears and disappears, the database server is struggling, which points at traffic spikes, a runaway plugin or a hosting limit rather than a wrong password.

Ask your host two direct questions: is the database server up, and has anything changed on your account, such as a password reset, a plan change or a migration? Hosts can often see connection-limit errors in their own logs, which settles the question quickly. If you recently moved hosts, assume the credentials differ until proven otherwise, because database names and users often carry a host-specific prefix.

What not to do

Do not change the table prefix in wp-config.php unless you know the tables were renamed. Do not drop tables to start fresh. Do not leave WP_ALLOW_REPAIR in the file after running repair, because the repair page requires no login. Do not paste your database password into forums or chat tools.

When to stop and call someone

Stop if the credentials are correct but the connection still fails, if the repair reports errors it cannot fix, if tables are missing, or if the host says the database was removed. Do not delete wp-config.php or reinstall WordPress over a live site; that can leave you with a fresh empty database and your real one orphaned.

How we fix it

Through WordPress emergency support we respond within 15 minutes with emergency credits, and rescue is pay-only-if-fixed. We verify credentials, repair tables, and when needed recover from a backup using backup and restore. If you need a project-sized recovery, post it here.

What does a database error look like on a real site?

Suppose a small shop moves host over a weekend, and on Monday every page shows the connection message. The database name and user on the new host both carry a prefix the old host did not use, but wp-config.php was copied unchanged. The fix is to correct two lines, DB_NAME and DB_USER, to the exact values shown in the new hosting panel. Nothing was lost; the site only needed to be told where its data now lived. Compare that with an intermittent error during a sale, where credentials are correct and the cause is too many simultaneous connections, which needs the host or a developer rather than a settings change.

How do I confirm the database itself is healthy?

  1. Open phpMyAdmin from the hosting panel and confirm you can see the tables, with the prefix your wp-config.php expects ($table_prefix).
  2. Check that the wp_options table, or the same table with your prefix, is present and has rows.
  3. Check the size of the database against any limit on the plan.
  4. Look in the panel for connection-limit or resource-usage warnings.
  5. Test the same database login from phpMyAdmin; if that works, the problem lies in wp-config.php, not the database.

What are the typical host-side fixes?

Hosts can restart the database service, raise a connection limit, restore a deleted database from their own backup, or reset a user's permissions. These are things you cannot do yourself on shared hosting, and asking for them clearly saves hours. A good request reads, "The site at this address shows a database connection error since this time. Credentials match the panel. Please check database service status and connection-limit logs."

Which fix fits which symptom?

SymptomLikely fix
Wp-admin shows a repair messageRun the built-in repair after a backup
Both front end and admin show the same errorCheck credentials and DB_HOST
Error is intermittentAsk the host about connection limits and load
Began right after a moveUse the new host's exact database name and user
Tables missingRestore from backup, see backup and restore

How do I prevent this?

  • Keep a tested off-site backup, including the database; see backup and restore.
  • Monitor uptime so you learn of outages before customers do.
  • Avoid heavy plugins on cheap shared hosting, and plan hosting for traffic peaks.
  • Write down database details when you change host.
  • Keep a copy of wp-config.php outside the web folder, minus any secrets you do not need to store.

Is repairing tables safe?

The built-in repair runs standard repair commands on the tables WordPress knows about. It is usually safe, but it cannot recover data that is already gone, so a backup beforehand is essential. If repair reports a table it cannot fix, stop and restore from a backup rather than repeating it.

Site down right now?

A person reads it, any hour. Emergency Rescue is pay-only-if-fixed.

FAQ

Questions people ask

14 answers. Can't find yours? Ask an engineer.

Is my data deleted?

Usually not. The message means WordPress could not connect, not that the data is gone. The most common causes are wrong credentials or a database server that is down or overloaded.

Link to this answer
Why does it work on some page loads and fail on others?

An intermittent error often means the database server is overloaded or hitting its connection limit. That is a hosting or traffic issue rather than a settings mistake.

Link to this answer
Can I see this error only in wp-admin?

Sometimes. WordPress shows a separate message about a corrupted database when it can connect but the tables need repair.

Link to this answer
Do I need a backup before touching anything?

Yes. Back up files and, if you can reach it, export the database before changing settings or running repair.

Link to this answer
What does Error establishing a database connection mean?

WordPress could not talk to its MySQL or MariaDB database. It connects on every request using four values from wp-config.php, and when that fails it shows this one message instead of loading anything.

Link to this answer
Did my host delete my database?

Usually not, but it can happen. If your tables are missing in phpMyAdmin or the host says the database was removed, stop and ask the host to restore from their backup. Do not reinstall WordPress over the live site.

Link to this answer
Why did the error appear right after I changed hosts?

Database names and users often carry a host-specific prefix. If wp-config.php was copied unchanged, DB_NAME and DB_USER may not match the new hosting panel. Correct them to the exact values the new host shows.

Link to this answer
Is it safe to run the WordPress repair page?

It is usually safe and runs standard repair commands on tables WordPress knows about. Take a backup first, and remove WP_ALLOW_REPAIR from wp-config.php straight afterwards because the repair page requires no login.

Link to this answer
What should I ask my host?

Ask whether the database service is up, whether any connection-limit errors appear in their logs, and whether anything changed on your account such as a password reset, plan change or migration. Say the exact time the error began.

Link to this answer
Can a full disk cause this error?

Yes. If the hosting account is out of disk space or quota, the database may fail to write or start. Check usage in the hosting panel and clear space, then test again.

Link to this answer
Should I change the table prefix in wp-config.php?

No, unless you know the tables were renamed. The prefix must match the tables in the database, otherwise WordPress looks for tables that do not exist and behaves as if the site were empty.

Link to this answer
How can I prevent this error?

Keep a tested off-site backup including the database, monitor uptime, avoid heavy plugins on weak shared hosting, and write down database details when you change host. Monitoring tells you about outages before customers do.

Link to this answer
Can I fix this without FTP or SSH access?

Often yes for credentials: the hosting panel shows the database name, user and host, and phpMyAdmin tests the login. Editing wp-config.php does need file access, so use the host's file manager or ask support.

Link to this answer
When should I stop and call someone?

Stop if the credentials are correct but the connection fails, repair reports errors it cannot fix, tables are missing or the host says the database was removed. Emergency support responds in 15 minutes and rescue is pay-only-if-fixed.

Link to this answer

Want an engineer on it?

Tell us what is wrong in plain words. A person reads it, today.