Site Down or Erroring
Error Establishing a Database Connection
Updated
Error establishing a database connection
What's happening
Your WordPress site has two halves. The files are the machinery: the theme, the plugins, your images. The database is the filing cabinet: every page, post, product, order, user and setting. To show a page, WordPress opens the cabinet and builds the page on the spot.
"Error establishing a database connection" means WordPress tried to open the cabinet and couldn't. Without it, WordPress can't build a single page, so visitors see that one line on a white background instead of your site. The message says the connection failed, not that the content is gone. In most cases your pages, posts and orders are sitting exactly where they were. WordPress just can't get to them right now.
Each form it takes is a clue:
- The whole site, every page, constantly. Something is wrong with the connection itself: the login details, or the database server.
- Visitors see the site, but the admin area shows the error. A caching plugin or your host is serving saved copies of your pages. The site is still down; it just doesn't look it yet.
- It comes and goes. That usually points to a database server that's overloaded rather than broken.
- Right after a move or a change at your host. A migration, a plan change or a password reset, and the login details WordPress has on file no longer match.
- During a busy period. A sale, a newsletter, a wave of bot traffic, and the error appears. The database likely hit a limit.
- "One or more database tables are unavailable. The database may need to be repaired." Same family, different message. WordPress reached the database, but one of the tables inside it is damaged or missing.
Why it happens
The usual causes:
- Wrong login details. WordPress keeps the database's name, username, password and address in a settings file. If any of those changed, through a move to a new host, a password reset or a rebuilt hosting account, WordPress knocks on the right door with the wrong key. The database is fine. The site can't get in.
- The database server is down or overloaded. The database runs as its own program on your host's server. If it crashes, restarts, or is swamped by other sites sharing the same server, every site on it shows this error until it recovers.
- The database ran out of room or hit a limit. Some cheaper hosting plans cap how big a database can grow and how many connections it can handle at once. Years of orders, form entries and page revisions can reach that cap unnoticed, and one busy afternoon tips it over.
- A damaged table. A server crash, a full disk, or an update that stopped halfway can leave a table in a broken state. That's where the "tables are unavailable" message comes from. The content is usually recoverable, but it takes a careful repair, not a guess.
- A hack. An attacker changes the database password, edits the settings file, or deletes tables outright. If the error arrived with an admin user you don't recognize, strange files, or a security warning from your host, treat it that way. From the outside, we can't tell a hack from a bad setting.
Your host can tell you some of this and not the rest. They can see whether their database server is up, whether your account has hit a limit, and whether there's a wider outage. They usually won't check your WordPress settings, repair a table, or work out what overloaded the site, because that's inside your site rather than their platform.
What you can safely try
- Confirm it's down for everyone. Check on your phone with Wi-Fi off, or see how to tell whether a site is down for everyone or just you. If visitors see the site but the admin area shows the error, a cache is covering for a site that is still down.
- Wait a few minutes and refresh. A brief overload or restart at the host clears on its own. If it keeps happening, you have a site that keeps going down, and the cause needs finding.
- Ask your host whether the database server is up, whether your account has hit a limit, and whether there's a known outage.
- Write down what changed. A migration, a plan change, a password reset, a new plugin, a big traffic day, a security notice. The timing usually points straight at the cause.
- Don't edit configuration files. The settings file that holds the database details is one typo away from a worse error.
- Don't run repair tools or scripts from a forum. A repair command run against a damaged table without a backup first can make the damage permanent.
- Don't restore a backup blindly. It can wipe out orders and form entries added since the backup, or bring the problem back with the content. Here's when restoring a backup is the right move.
When to call us
If the error is still there after a refresh and a word with your host, this is a standard repair for us. In plain terms: we check that the database details WordPress holds match what the host has; confirm the database server and your account's limits with the host; take a copy of the database as it stands, then repair any damaged tables; bring content back from a backup if a table is beyond repair; and look at what overloaded or broke it, so it doesn't happen again. If it turns out to be a hack, we tell you and treat it as a hacked site instead.
An Emergency Fix starts at a flat $149. We look at the site, confirm the price, and you approve it before we touch anything. Here's what fixing a broken site costs. If you'd rather not think about the next one, every care plan includes unlimited break-fix support.
Common questions
- Is my website data gone?
- Almost certainly not. This error means your site can't *reach* its database, not that the data is deleted. Once the connection is restored, your content is right where you left it. The exception is a damaged table or a hack that deleted data, which is why a recent backup matters.
- Will this fix itself?
- Sometimes. A brief overload or restart at your host can clear on its own within a few minutes. If it doesn't, or it keeps coming back, the site stays down until the underlying cause is fixed, so it's not something to wait on for long.
- I just moved my site to a new host and now I get this error. What happened?
- Most likely the database login details WordPress has on file don't match the new host's database. The move copied your files and content, but the settings still point at the old database name, user, password or address. The content is usually fine; the connection details need correcting.
- Does this error mean I've been hacked?
- Usually not, but it can. An attacker who changes the database password or deletes tables causes exactly this error. From the outside, a hack and a wrong setting look identical. If the error arrived alongside unknown admin users, strange files or a security warning from your host, treat it as a possible hack until it's checked.
Related terms
Want this fixed for you?
Emergency WordPress Fixes
From $149, flat rate. You approve the price before we start.
Not an emergency? Get a free audit of your site, done by a person, no obligation.