🔧 Flat-price WordPress fixes from $69 — start with a free diagnosis, no card. Get a free diagnosis →

Errors

Error Establishing a Database Connection: A Real Fix

Oct 8, 2026 · 8 min read · By the Mend engineering team

If WordPress says “Error establishing a database connection,” it means your site can’t talk to its database at all. The fastest safe fix is to check your database credentials and whether the database server itself is online, then work outward from there.

This error is usually caused by one of four things: wrong database login details, a down or overloaded database server, a corrupted database, or a broken hosting environment after a change. The trick is not to guess; you want to test the most likely cause in a sensible order so you don’t make a small issue worse.

What this error actually means

Every WordPress page needs two parts: the files on your server and the database that stores posts, pages, settings, users, and more. When the database connection fails, WordPress can’t load even a basic page because it has nowhere to fetch its content from.

That’s why this error can appear site-wide, in the admin area, or only on certain requests depending on what exactly is broken. It is also why the same error can have very different root causes on different hosts.

What you’re likely seeing

You may see a plain white page with the error message, or your site may partially load and then fail. In some cases, the front end is down but the host control panel, phpMyAdmin, or a database monitor still works.

Common signs include:

  • The homepage and wp-admin both show the error.
  • The problem started right after a migration, password change, plugin update, or hosting incident.
  • Other sites on the same hosting account still work, but this WordPress install does not.
  • Your host reports database maintenance, high load, or connection limits.

The most likely causes, in order

1) Wrong database credentials

WordPress stores its database name, username, password, and host in wp-config.php. If any of those values are wrong, WordPress cannot connect.

2) Database server unavailable or overloaded

The database service may be offline, under maintenance, too busy, or rejecting new connections. This is common on shared hosting during spikes or when the host is having trouble.

3) Corrupted tables or a damaged database

If the database is reachable but one or more tables are broken, WordPress may still fail to connect cleanly or may crash during early loading.

4) Hosting or environment changes

A PHP update, server migration, changed database host, or resource limit can break a site that was working minutes before. The timing often points to the real cause.

How to fix it safely

Before you change anything, take a backup if you can. If the site is down and you have access to hosting backups, create one from the host side first. If the database itself is inaccessible, at least save copies of the files you can reach.

Step 1: Check whether the database server is actually up

Start with your hosting panel. Look for database status, service alerts, resource warnings, or maintenance notices. If your host uses cPanel, Plesk, or a custom panel, the labels will vary.

If you can open phpMyAdmin or another database tool, try connecting there. If that fails too, the problem may be on the database server side rather than in WordPress.

If the host says the server is under load or down, the safest move is to wait for recovery or open a support ticket. This is often the fastest fix and the one most people overlook.

Step 2: Verify the database details in wp-config.php

Open wp-config.php and check these values:

  • DB_NAME
  • DB_USER
  • DB_PASSWORD
  • DB_HOST

Compare them against the database details in your hosting panel. If the site was migrated recently, the host may have changed the database host value even if the other details stayed the same.

If you need to reset the database password in your host panel, update the password in both places. One mismatch is enough to cause the error.

Step 3: Test the database connection directly

If you have access to phpMyAdmin, confirm that the database exists and that the user has the correct privileges. A user without permission can sometimes look like a connection problem from WordPress’s side.

Also check whether the database name in wp-config.php matches the one in your hosting panel exactly. Typos, wrong prefixes, and copied staging credentials are common after migrations.

Step 4: Repair the database if it may be corrupted

If the connection details are correct and the server is online, corruption is a likely next step. WordPress has a built-in repair mode you can enable temporarily by adding the following line to wp-config.php:

define('WP_ALLOW_REPAIR', true);

Then visit the repair URL shown in WordPress documentation for your install, run the repair option, and remove that line immediately afterward. Leave repair mode enabled only long enough to fix the database.

This can repair common table damage, but it will not solve a dead database server or wrong credentials.

Step 5: Check for a corrupted core file or bad deployment

Less often, the error follows a broken upload, incomplete update, or damaged core file set. If this happened right after a change, compare the timing and consider restoring the site from a known-good backup.

If you recently updated WordPress, a plugin, or a theme and then the error appeared, see WordPress Site Broke After an Update? Here's What Happened and How to Fix It for the safest rollback approach.

Step 6: Restore from backup if the database itself is damaged

If you have a clean backup from before the error started, restoring that backup is often the quickest reliable fix. This is especially true when a table repair helps only briefly or the data appears inconsistent.

Restore carefully, and confirm whether your backup includes both files and database. Restoring only one side can leave the site half-fixed.

How to tell whether this is your host or your site

A useful rule: if multiple sites on the same account are affected, or the database tool itself will not connect, the issue is probably hosting-side. If only one WordPress install is broken and everything else on the server looks fine, the problem is more likely in that site’s configuration or database.

If the error started after a change you made, begin with that change. If it started without warning, check host status and recent server activity first. That simple split saves a lot of time.

What not to do

  • Don’t keep random editing wp-config.php values without comparing them to the host panel.
  • Don’t run database repair on a live site without understanding whether you have a backup.
  • Don’t reinstall WordPress core until you know the database is reachable.
  • Don’t assume caching is the cause; this error happens below the cache layer.
  • Don’t ignore host warnings about resource limits or MySQL outages.

How to prevent this from happening again

The best prevention is boring and effective: keep backups, track changes, and use reliable hosting. A good maintenance routine makes it much easier to tell whether a database error is a configuration issue, a server issue, or a bad update.

For a practical baseline, see What a Good WordPress Maintenance Routine Looks Like. If you want a broader reference for future troubleshooting, keep How to Fix the WordPress "Error Establishing a Database Connection" Error bookmarked as well.

Also make sure you know how your host handles restores and database backups before you need them. The time to learn that is not while the site is down.

When to call a professional

Call for help if the site is down for customers, the database server status is unclear, you’re not confident editing wp-config.php, or repairs fail and you need the site back quickly. Database issues can cascade into data loss if they’re handled in the wrong order.

If you want a senior engineer to inspect the site, isolate the root cause, and fix it on a backup-first workflow, Mend can do that fast. Start with a free diagnosis at /start/diagnosis, or if the site is business-critical and you need urgent recovery, use /start/emergency. If you’re ready to hand over secure access without sharing passwords, use /connect.

Mend’s paid fixes come with a plain-English report of what broke and what changed, flat up-front pricing, and a fixed-or-your-money-back guarantee. That’s useful when the error is tied to the database, the host, and a recent change and you do not want to spend the day guessing.


If this error followed a migration or host switch, the problem is often in the database host or credentials rather than WordPress itself. If it follows a plugin or core update, the database may be fine and the server path is what changed. Working that distinction early is the difference between a quick fix and a long outage.

Frequently asked questions

Is this error always caused by the database being down?

No. It can also be caused by wrong credentials, an incorrect database host, a corrupted database, or hosting limits that block new connections.

Can I fix this from the WordPress dashboard?

Usually not, because the dashboard also depends on the database connection. You normally need hosting access, file access, or both.

Is it safe to use WordPress database repair mode?

It can be safe if you use it briefly and remove it right after, but make a backup first if possible. It is meant for fixing database table issues, not server outages or bad credentials.

What if my host says everything is fine but the error continues?

Then the likely causes are in wp-config.php, database permissions, or database corruption. At that point, compare the live settings carefully or get a second set of eyes on it.