Skip to content

Database Connection Error Fix for WordPress

Every page on your site has been replaced by "Error establishing a database connection". Your content is almost always still there; WordPress just cannot reach it. We work out which part of the connection has failed and restore it without putting your data at risk.

Backup before every change Clear upfront pricing WhatsApp support No lock-in contract
What's Included

What We Cover

Every engagement includes the items below. If your situation needs something different, we discuss it before we start — no surprises.

Copy of site files and, where reachable, an export of the database before any work
Checking DB_NAME, DB_USER, DB_PASSWORD and DB_HOST in wp-config.php against the hosting panel
Confirming the database user still has permission on the right database
Checking whether the database server is up, overloaded or hitting its connection limit
Repairing damaged tables on a copy before the live database
Raising server-side faults with your host, with the evidence they need
Removing the WP_ALLOW_REPAIR line and any other temporary changes afterwards
Looking for signs of tampering if credentials changed unexpectedly
A short report on the cause and how to reduce the chance of it returning

Who Is This For?

  • Site owners whose every page shows the database connection message
  • Shops and booking sites that go offline at busy times
  • Anyone whose site broke straight after a host move or password reset
  • Owners told by their host that "everything is fine on our side"
  • Agencies managing several sites on one account that all failed together
Two people looking at a laptop together
On this page

Why this error takes the whole site down

Every page on a WordPress site is assembled from the database on request: the posts, the menus, the settings, the user accounts, the orders. When WordPress cannot reach that database at all, there is nothing to build a page from, so it stops and prints one sentence: “Error establishing a database connection”. The home page, the blog, the shop and the login screen all show the same line.

The good news is that the content is very rarely lost. In most cases the data is sitting safely on the server and WordPress simply cannot get in. The work is in finding out which link in the chain has broken. This error is one of several that can take a site offline, and our overview of WordPress errors and how to fix them shows where it fits among the others.

The chain WordPress relies on

To connect, WordPress reads four values from wp-config.php in the site’s root folder:

  • DB_NAME, the name of the database;
  • DB_USER, the database username;
  • DB_PASSWORD, that user’s password;
  • DB_HOST, the server the database lives on, often localhost but sometimes a separate address your host provides.

It then knocks on the database server’s door with those details. The connection fails if any value is wrong, if the database server is not answering, if it is answering but refusing new connections, or if that user no longer has permission to use that database. Each has a different fix, which is why trying random things wastes time.

Common causes, and how each one tends to show itself

Changed or mistyped credentials

Someone reset the database password in the hosting panel, a developer edited wp-config.php, or the site was moved and the new values were never filled in. This usually starts at a clear moment you can point to. After a move between hosts it is especially common, and the post on errors that appear after a migration lists the other things that tend to go wrong at the same time.

The database server is down or overloaded

On shared hosting, the database server is used by many sites. If it crashes, restarts or is swamped, every site on it may show this error at once. A tell-tale sign is that the site comes and goes, working one minute and failing the next, often at busy times. Traffic spikes, bad bots and slow queries from a heavy plugin can all push a small database server past its limits.

Too many connections

Hosts cap how many connections one account may open. A burst of visitors, a crawler, or a plugin that opens connections and does not release them quickly can hit that cap. The site recovers on its own once the load drops, then fails again later.

Corrupted tables

A crash during a write, a full disk, or an interrupted import can damage a table. Sometimes the front end shows the connection error while /wp-admin/ shows a different message saying one or more database tables are unavailable and the database may need to be repaired. That second message is a strong hint that the credentials are fine and the data itself needs attention.

Account limits or suspension

If a hosting account has run out of disk space, gone over a resource limit or has an unpaid invoice, the host may stop the database service for it. The site files can still be served while the database refuses every request.

Tampering

Less often, credentials change because someone with unauthorised access changed them, or a malicious script has filled the database with junk. If you also see unknown admin users or spam content when the site does load, read about cleaning a hacked WordPress database before simply reconnecting things.

Checks you can do before calling anyone

First, protect what you have. Download a copy of the site files and, if the hosting panel lets you, export the database through phpMyAdmin or the host’s own backup tool. Our step-by-step piece on backing up a WordPress site covers the usual methods. If the database will not export, at least save the files, especially wp-config.php.

  1. Check whether it is only your site. If you have other sites on the same hosting account and they also show the error, the problem is almost certainly on the server side.
  2. Look at your host’s status page or recent emails. Maintenance windows, outage notices and suspension warnings explain a lot.
  3. Compare the credentials. Open wp-config.php in the file manager and compare the four values with the database and user listed in the hosting panel. A single wrong character is enough. Do not change the password in the panel unless you also update the file to match.
  4. Try logging in to phpMyAdmin. If the host’s database tool opens your database and shows tables, the database server is alive and the data exists. That points back at the credentials or the user’s permissions.
  5. Check that the user is attached to the database. Many panels let you see which users are assigned to which database. A user created but never granted access to the database will fail every time.

About the built-in repair tool

WordPress includes a repair script for damaged tables. It is switched on by adding define( 'WP_ALLOW_REPAIR', true ); to wp-config.php and then visiting /wp-admin/maint/repair.php. That page works without logging in, which is exactly why the line must be removed again as soon as you are done. Only use it when the messages point to damaged tables, and only after the database has been backed up. It cannot help if the server is down or the password is wrong.

When this is not something to handle alone

Bring in help when phpMyAdmin will not connect either, when the host says everything is fine but the error continues, when tables fail to repair, or when the error keeps returning under load. Recurring failures at peak times are usually a capacity or query problem, not a broken setting. Sometimes the honest answer is that the hosting plan cannot carry the site any more, and our hosting and domain support can help you move to something steadier. Similar intermittent behaviour shows up in the gateway errors described in what 502, 503 and 504 errors mean, so it is worth ruling those out too.

If the site is completely offline right now and you do not know where to begin, the emergency page for a site that is down tells you what to send us so we can move quickly.

Our approach to a database connection failure

Message us on WhatsApp or through the contact form with a screenshot of the error and, if you know it, the name of your host. We look, tell you honestly what we think is going on and when we can start. A shop that cannot take orders is handled as urgent.

We begin by saving the files and, if it can be reached, the database, so nothing we try can make things worse. Then we work down the chain in order: credentials, user permissions, database server status, connection limits and table health. Each step either rules a cause out or confirms it, so we are not guessing.

If the fault is on the host’s side, we gather the evidence and raise it with their support in terms they cannot brush off, then confirm the fix once they act. If the tables are damaged, we repair them from a copy first and only touch the live database once the repair checks out. If credentials were changed by someone who should not have access, we treat it as a security incident and make sure that access is closed.

Once the site is back, we look at why it happened. A database that has grown heavy with old revisions, expired transients and leftover plugin tables puts extra load on the server; our notes on keeping the WordPress database lean explain that housekeeping. You get a short write-up of the cause and what we changed. If you are outside India, our team is in India and keeps IST hours, and we accept payment by PayPal or Wise.

A connection error that turns out to be part of a bigger fault in plugin or theme code moves to our bug fixing service for WordPress, and if the server is returning a generic 500 page rather than this message, see the fix for WordPress 500 errors.

Common Problems

Problems We Fix

If what is happening to your website is on this list, we have fixed it before. If it is not, tell us anyway — the list is the common ones, not the only ones.

Credentials out of step

The password changed in the hosting panel but wp-config.php still holds the old one.

Site comes and goes

The shared database server is overloaded or connections run out during traffic peaks.

Tables need repair

wp-admin reports unavailable tables because a crash or full disk damaged them.

Broken after a move

The new host uses a different database host value or user that was never filled in.

Account limits reached

Disk space, resource caps or a billing hold have stopped the database service.

How It Works

Our Process

A straightforward process so you always know what is happening and what comes next.

  1. Step 1 of 6

    You send a screenshot of the error and tell us who hosts the site

  2. Step 2 of 6

    We save the files and try to export the database

  3. Step 3 of 6

    We test each link in order: credentials, user rights, server status, connection limits, tables

  4. Step 4 of 6

    We fix the broken link, repairing tables on a copy first where needed

  5. Step 5 of 6

    We involve the host if the fault is on their server and confirm their fix

  6. Step 6 of 6

    We check pages, forms and checkout, then send you the write-up

FAQ

Database Connection Error Fix — Common Questions

Questions people ask about database connection error fix.

Very unlikely. This error means WordPress cannot reach the database, not that the data is gone, and in most cases it is intact on the server.

A message in wp-admin saying tables are unavailable and may need repair usually means the login details work but some tables are damaged.

Intermittent failures usually point to the database server being overloaded or the account hitting its connection limit, rather than wrong settings.

Only after a full database backup, and only if the messages point to damaged tables. The repair page needs no login, so remove the line straight afterwards.

Ask them to check the database service and connection limits for your account specifically, then compare the wp-config.php values yourself, or let us gather the evidence for them.

Restoring overwrites anything newer, such as orders and enquiries. Find the cause first; restoring is a last resort, and our notes on a restore that goes wrong explain why.

Still have a question? We are happy to help.

Ask Us Directly

We do not guarantee sales, leads, or Google rankings. We help improve the technical setup, user experience, reliability, and clarity of your website so your marketing has a stronger base.

Ready to Get Started?

Your Website Deserves Proper Care

Get a free, no-pressure website health check. We'll tell you exactly what needs attention and what it will cost — before you commit to anything.

No hidden fees Backup before every change Clear communication in Hindi or English India-based team