Error Establishing a Database Connection: How to Fix It
Error establishing a database connection means WordPress is running fine and the database that holds everything you have ever published is not answering it. The most common cause is the one you cannot fix and should not pay for.

The short answer
- The message means WordPress itself loaded but the database holding your pages, posts and orders did not answer. Your content is almost always still there.
- Four causes account for nearly all of them: wrong database details in wp-config.php, a database server that is down or over its limit at your host, a corrupted database table, or a hacked site.
- Open a second site on the same hosting account before you do anything else. If it is down too, this is your host’s job and nothing in WordPress will fix it.
- WordPress’s own repair tool works without anyone being logged in, so the line that switches it on has to be taken out the moment you are done.
- Our On-Demand WordPress development is $25 an hour if you want it fixed today, and care plans start at $49 a month per site for the monitoring and backups that stop most repeats.
Error establishing a database connection means WordPress is running fine and the database that holds everything you have ever published is not answering it. Four things cause nearly all of these: the database login details in your wp-config.php file are wrong, the database server at your host is down or over a limit, a database table is corrupted, or someone has been in your site. The first thing worth knowing is that the most common cause is the one you cannot fix and should not pay for.
This is written for the person whose site it is, not for the person with server access. By the end you will know which of the four causes you have, the order to work through them, what the outage is doing to your search results while you read this, and what the job costs if you decide to hand it over. If your site is showing a different message, our guide to the WordPress critical error screen covers that one.
Your content is in the half that did not answer
A WordPress site is two separate systems that have to talk to each other. The files are WordPress, your theme, your plugins and your uploaded images. The database is a separate program, usually MySQL or MariaDB, and it holds every page, post, product, order, customer, comment, user account and setting.
When you see this message, the files loaded. WordPress started, read its configuration, tried to open the database and got no useful reply. That is why the page is a bare white screen with one sentence on it rather than a broken-looking version of your site: WordPress never got far enough to know what your site looks like.
It also explains why panic is usually unnecessary. A database that refuses a connection is not a database that has been emptied. In the great majority of cases the data is sitting there intact and the problem is the handshake, the hosting account or one damaged table.
Two minutes that tell you whose problem this is
Almost every guide to this error starts by telling you to edit wp-config.php. That is the wrong first move, because it assumes the fault is yours. Do these four checks first, in this order. They take about two minutes and they decide whether you need to do anything at all.
- Open another site on the same hosting account. If you have a second site, a staging copy or even a subdomain there, load it. If it shows the same message, the database server is the problem and it is your host’s to fix.
- Try to log in to your hosting control panel. If the panel itself is slow or refusing to load, you have a hosting incident rather than a WordPress one.
- Look at the host’s status page and your email. Hosts post database and server incidents there, and they often email about accounts that have hit a resource limit before the site goes down.
- Load
/wp-admin/. If the admin shows the same error, the connection is failing everywhere. If the front end errors but the admin loads, you are usually looking at one corrupted table rather than a dead connection.
If checks one to three point at your host, phone or chat to them now and stop reading. There is nothing to fix on your side, and a developer cannot restart someone else’s database server either.
Symptom, likely cause and who fixes it
| What you are seeing | Most likely cause | Who fixes it |
|---|---|---|
| Every site on the hosting account shows it, including the control panel being slow | Database server down, or the account is over a resource limit | Your host, usually within the hour |
| It appeared straight after a host move, a domain move or a site migration | Database name, user, password or host value in wp-config.php no longer matches | You or whoever did the move, in minutes |
| It appeared after someone reset a password in the hosting panel | The database password was changed without updating wp-config.php | You, in minutes |
| Front end errors, wp-admin loads, or a suggestion that the database may need repairing | One or more corrupted tables | You with the repair tool, or a developer |
| It comes and goes, worst at busy times of day | Too many connections for the plan, often a plugin or a traffic spike | Your host first, then a developer for the cause |
| It started with other odd behaviour: strange admin users, redirects, warnings in Google | The site has been compromised | A security specialist, not a restore on its own |
| Nothing has changed, the host says the database is fine, and it will not come back | Corrupted files or a broken WordPress install | A developer |
Work down the table from the row that matches you. The rows are ordered roughly by how often we see them, and the top two account for most of the calls we get.
Fix 1: the four database details in wp-config.php
WordPress keeps the database login in a single file called wp-config.php, in the top folder of your site. The WordPress documentation on common errors puts this first: the error is usually caused by an error in that file, so check the database name, the database username, the database password and the database host against what your hosting panel says.
You can read that file through your host’s file manager without any special software. Four lines matter, and they look like define( 'DB_NAME', ... ), DB_USER, DB_PASSWORD and DB_HOST. Compare each against the database section of your hosting panel, character for character. Database names and usernames usually carry an account prefix, so mysite_wp and c1234x_mysite_wp are different databases and one of them does not exist.
The host value is the one people get wrong. Most shared hosting uses localhost, but plenty of hosts use a dedicated database server name or an internal IP address instead, and some use a port. Take it from the hosting panel rather than from a tutorial.
If the password looks correct and the error persists, WordPress suggests resetting the database password manually in your hosting panel and putting the new one in the file. Make a copy of wp-config.php before you change a character, and never paste the file’s contents into a support chat or a forum: it contains the keys to your whole site.
Source: the WordPress common errors documentation on developer.wordpress.org, last modified October 14, 2026. Checked November 15, 2026.
Fix 2: a database server that is down or over its limit
The same WordPress documentation names two host-side causes: the database has met its quota and has been shut down, or the server is down. Both are outside WordPress, and both are common on shared hosting.
Quota suspensions catch people out because nothing on the site changed. Shared plans cap disk space, database size and the number of simultaneous database connections. A site that grows, a plugin that logs every page view, or a WooCommerce store that keeps years of order history can cross one of those lines on an ordinary Tuesday. When you contact the host, ask three specific questions: is the database server running, has this account been limited or suspended, and how many connections does the plan allow.
Vague questions get vague answers here. Those three get you a cause you can act on, which is either a plan upgrade, a cleanup or a genuine fault on their side.
Fix 3: repairing a corrupted database table, carefully
Tables get corrupted when a database is interrupted mid-write, usually by a server crash, a full disk or a hard reboot. WordPress has a built-in repair tool for exactly this, and it is deliberately switched off until you switch it on.
You add one line to wp-config.php, define( 'WP_ALLOW_REPAIR', true );, then visit /wp-admin/maint/repair.php on your own site and run the repair. The WordPress documentation is blunt about the catch: when it is enabled, a user does not need to be logged in to access it, because the whole point is that people often cannot log in when the database is corrupt. It also says the feature should only be enabled if needed and disabled once the issue is solved.
Read that twice before you use it. While that line is in place, anyone who knows the address can run database operations on your site. Take the line out as soon as the repair finishes, and take a backup before you start, because a repair on a badly damaged table can lose rows.
Source: the WordPress wp-config.php documentation, Automatic Database Optimizing section, last updated October 14, 2026. Checked November 15, 2026.
Fix 4: restoring a backup, and when that is the wrong move
A restore is the right answer when a table is damaged beyond repair or an update has left the database in a state nobody can unpick. It is the wrong answer in two situations that come up constantly.
The first is when the database is fine and the credentials are wrong. Restoring then overwrites good data to fix a four-line text file, and you lose everything published since the backup for no reason. The second is when the site has been compromised, because the backup may already contain the way in.
There is also a quieter trap. A database-only restore puts old content back under current files, and a files-only restore does the reverse. Both leave a site that half works. If you are not certain which halves your backup contains, our guide on choosing between a backup plugin and host backups covers how to check before you restore anything.
When this error means someone has been in your site
WordPress lists a compromised website as the third cause, and advises checking wp-config.php and confirming with your host before assuming it, then scanning the site. We would add the practical tell: a hack rarely shows up as a database error on its own. It arrives with company.
Treat it as a security problem rather than a database problem if the outage came alongside administrator accounts nobody created, visitors being sent to other websites, a warning in Google Search Console, or a site that works for you and misbehaves for everyone else. In that case start with what to do when a website is hacked, and bring in WordPress malware removal rather than restoring and hoping. Cleanups start at $99, and most come in between $99 and $299 depending on how far the infection spread.
What the outage is doing to your search results
This is the part the hosting tutorials leave out, and it is the part that costs money quietly. While your pages return an error, Google is still crawling them.
Google’s own guidance on temporarily disabling a website is specific. If you need to urgently disable a site for a day or two, return an informational error page with a 503 status code rather than all of your content, and treat whole-site blocking as something for a very short period, a few days at most. Do not return a 503 for your robots.txt file, because that blocks all crawling. Do not use 403, 404 or 410 to block the site, because those will remove the site’s URLs from Google Search. For anything longer, serve an indexable placeholder home page with a normal 200 status instead. Google also notes that while a page returns a 503, its systems cannot refresh the titles, descriptions, metadata or structured data for that page.
In practice, a database error page is none of these things. It is a bare page served with whatever status your setup happens to produce, with no explanation for a visitor and no signal for a crawler. A short outage of an hour or two is very unlikely to move rankings. A site left in that state for days is a different matter, and if you cannot get the database back quickly, a static holding page is a better thing to be serving than an error.
Source: Google Search Central, temporarily pause or disable a website. Checked November 15, 2026.
Orders and enquiries sent during the outage are not waiting for you
Because the database is where everything is written, nothing submitted while it is unreachable gets saved. A contact form that cannot write a record and cannot queue an email has nowhere to put the enquiry. A checkout that cannot create an order record cannot take the order.
For a brochure site that means some lost enquiries you will never know about. For a store it can mean a payment taken by the card processor with no matching order on your side, which is why the first job after a store comes back is reconciling the payment provider’s dashboard against your orders list for the outage window, not admiring the homepage.
From our projects: On a WooCommerce build like the multi-brand commerce platform we built for Norske, every product, price, stock level and order lives in the database, so a connection failure takes the catalogue and the order history offline together while the files sit there untouched. That is why our WordPress care plans include uptime monitoring with alerts on every tier: on a store, knowing within minutes is worth more than any fix, and the Priority plan at $199 a month tests the checkout weekly for the same reason.
Why it keeps coming back
A single database error is bad luck. The same error three times in a month is a symptom, and the cause is nearly always one of four things.
- The plan is too small for the traffic. Connection limits are hit at busy times, so the error follows your visitor graph. It will look random until you compare the times.
- A plugin is writing far too much. Analytics loggers, security plugins that record every request and abandoned-cart tools can add millions of rows. The database grows until it crosses a quota.
- The database has never been cleaned. Years of post revisions, expired transients and orphaned metadata make every query slower, which makes timeouts more likely under load.
- Nobody is watching. The outage is found by a customer rather than an alert, so it is already an hour old by the time anyone looks.
If the error correlates with your busiest hours, the honest answer is often that the hosting plan, not the code, needs to change. We will say that even though it sends the money to your host rather than to us. Where the cause is a bloated database or a badly behaved plugin, the fix is a cleanup and a replacement, and a site that is slow before it fails usually gives you weeks of warning first.
What it costs to hand this to someone
Most of these jobs are an hour of work once someone knows where to look. Our published prices for the work involved, from our pricing page:
| What you need | Our price | What it covers |
|---|---|---|
| Someone to diagnose and fix it now | $25 an hour | On-Demand WordPress development, with a time estimate before work starts and a time report with the invoice |
| A cleanup after a hack | From $99 one-time | Full malware cleanup, hardening and blacklist removal, within 24 to 48 hours. Same-day work starts from $179 |
| A site rebuilt because the database is gone | $149 one-time, up to 20 pages | Website recovery from backups or archives, with a free check of what is recoverable before you pay |
| Moving to hosting that can cope | $79 one-time | Hosting or domain move, including files, database, SSL and a zero-downtime switch |
| Monitoring and backups so it does not happen twice | From $49 a month per site | Care plan with daily off-site backups, 30-day history, updates tested first, security and uptime monitoring |
Every project starts with a fixed written quote, so the price is agreed before any work begins, and care plans are per website with no contract. Hosting stays in your own account and is paid directly to your host, which matters here: when the cause is a hosting limit, you want to be the one who can upgrade the plan at two in the morning.
Database connection error questions
What does error establishing a database connection mean?
It means WordPress loaded but could not open the database that stores your content. WordPress reads its database name, username, password and host from wp-config.php, sends them to the database server and waits. If the details are wrong, the server is down, the account is over a limit or a table is corrupted, there is no reply and WordPress prints this one sentence instead of your site.
How do I fix error establishing a database connection in WordPress?
Rule out your host first, then check the credentials. Load another site on the same hosting account and your hosting control panel: if either is also failing, contact the host. If they are fine, compare the four database values in wp-config.php against your hosting panel. If those match, ask the host whether the account has hit a quota, and only then look at repairing tables or restoring a backup.
Why do I see this error when visiting someone else’s website?
Nothing is wrong with your computer or your browser. The error is generated by that website’s own software, so refreshing, clearing your cache or switching browsers will not change it. All you can do is come back later, or tell the site owner if you know them. It is usually fixed within a few hours.
Will I lose my content or my orders?
Almost never for content that was already published, because a refused connection does not delete anything. What you do lose is anything submitted during the outage: form enquiries, comments and checkout attempts have nowhere to be written. After a store comes back, check your payment provider’s dashboard against your orders for that period.
Is this my host’s fault or mine?
Your host’s, more often than not, and there is a two-minute test. If every site on the account is down, or the control panel is struggling, it is theirs. If one site is down and nothing changed on it, it is still probably theirs. If the error appeared immediately after a migration, a password reset or someone editing files, it is yours and it is quick to fix.
How long does the error usually last?
Minutes to a few hours. A host-side database restart or a lifted quota is often resolved within the hour once you have reported it. A credentials mismatch takes minutes once someone compares the file with the hosting panel. Outages that run into days usually mean a corrupted database or a compromised site, which are repair jobs rather than restarts.
Can too much traffic cause a database connection error?
Yes, and it is a common cause of the intermittent version. Shared hosting plans limit how many database connections run at once. A newsletter, an ad campaign or a post doing well can push past that ceiling, so the site errors for some visitors and works for others, then recovers on its own. Compare the outage times with your traffic before blaming a plugin.
Does a database error hurt my Google rankings?
Not for a short outage. Google expects sites to be unavailable occasionally and its guidance treats a day or two as something to handle with a 503 response, not a penalty. The risk is duration: a site that serves errors for days gives Google nothing to index and, as Google notes, it cannot refresh a page’s title, description or structured data while that page is failing. If the fix will take days, serve a holding page instead.
Is the WordPress database repair tool safe to use?
It is safe if you back up first and switch it off straight afterwards. WordPress’s documentation warns that while the repair feature is enabled nobody needs to be logged in to use it, by design, so leaving the line in wp-config.php leaves that page open to anyone who finds it. Repair, confirm the site loads, then remove the line.
How much does it cost to have someone fix a database connection error?
Usually one hour of work. Our On-Demand WordPress development is $25 an hour with an estimate agreed before anyone starts, which covers diagnosis and the fix for the credential, quota and corrupted-table versions. A hacked site is a different job and starts at $99 for a full cleanup. If the cause is your hosting plan, the money goes to your host, not to a developer.
Get the site back, then stop it happening again
Attors Technologies is a web development agency that builds and maintains WordPress sites for businesses in the US, UK and Europe. Send us the error, your host’s name and what changed recently. We will tell you which of the four causes it is before you commit to anything, and if it turns out to be your host we will tell you that too.
Sources
- common errors documentationdeveloper.wordpress.org/advanced-administration/wordpress/common-errors
- wp-config.php documentationdeveloper.wordpress.org/advanced-administration/wordpress/wp-config
- temporarily pause or disable a websitedevelopers.google.com/search/docs/crawling-indexing/pause-online-business
Keep reading
More in Performance & ReliabilityPerformance & Reliability
WordPress Backup Plugin or Host Backups? How to Choose
Use a WordPress backup plugin and your host backups together. They fail in different ways, so the real question is where the copies live and who restores them.
Performance & Reliability
WordPress Staging Site: When You Need One and What It Costs
Most business WordPress sites benefit from a staging site, and any site that takes money should not change anything without one. Here is which changes need it, what it costs and how to avoid losing orders.
Performance & Reliability
How to Recover a Deleted WordPress Site (Step-by-Step)
Your hosting company is the first call: most deleted WordPress sites come back from the host's own backups. Here is what to try, in order, and what to do if no backup exists.



