When your WordPress site shows “Error establishing a database connection,” the message means WordPress can’t reach its database, the place where it keeps the site’s pages, posts and settings. Without that connection, the site can’t load. The two places to look first are the database settings in a file called wp-config.php and your web host.
While the message shows, visitors can’t reach the site. No pages, no contact form and no ad landing page will load until the connection is back. The good news is that the first checks cost nothing. Here’s the plan: check what changed, check the four settings if you can, ask your host, and back up before you change anything.
What Does the Error Establishing a Database Connection Message Mean?
WordPress’s handbook says the message means there’s a problem with the connection to your database, and that there can be a number of reasons for it. In plain terms, the site and its database have stopped talking. The fix depends on which link in that chain broke, so the checks go in order.
Here’s why that matters. The database holds the words on your pages, your posts and your settings. WordPress reads from it each time a visitor loads a page. When the connection fails, the site has nothing to show. The causes that follow come from WordPress’s handbook page on errors.
The handbook lists those causes in an order. It points first to the database settings in wp-config.php. Next comes the web host. Only once both are ruled out does it raise the chance of a hacked site. Work through them in that order.
If your screen talks about a critical error instead, that’s a separate message with its own first step, and we explain what a WordPress critical error means in its own post.
What Should You Check First?
Start by making sure the problem isn’t on your own device. Reload the site in a private browser window, then on a phone or another computer. Next, think back to what changed shortly before the message appeared. Those two checks cost nothing and point you toward the next step.
- Reload the site in a private browser window, then on your phone with Wi-Fi turned off. This rules out your own device or network.
- Write down what changed shortly before the message showed up, such as a host move, a password change or an edit to a configuration file. Take a screenshot and note the time you first saw it.
- If you or your developer can open wp-config.php, check its four database settings against what your host lists for the database. The four settings are explained below.
- Look at your web host’s control panel or status notices for an outage or a full database.
- Contact your host with the exact message and the time you first saw it.
You can do the last three steps in whatever order feels comfortable. None of them needs a reinstall, and none of them deletes anything.
Is Your wp-config.php File the Problem?
WordPress’s handbook points first to an error in wp-config.php, the file that tells WordPress how to reach its database. It names four settings to check: the database name, the database username, the database password and the database host. Each one has to match the database itself.
Here’s what each one means from your side. The database name is the name of the database WordPress should use. The username is the account WordPress signs in with. The password belongs to that account. The host is the server where the database lives. All four must match what the database has on record.
Make a copy of wp-config.php before you open it. One wrong character in a setting can keep the site down, and a copy lets you put things back. If you’d rather not edit the file, that’s fine. Hand this check to your host or a developer.
If the settings are right, the handbook suggests resetting the database password by hand. That’s a job for your host or a developer. Keep in mind that a changed password has to be entered in wp-config.php too, or the two won’t match.
When Is Your Web Host the Cause?
WordPress’s handbook says the next step is to contact your web host. It names two hosting issues that can cause the message. The database may have met its quota, the limit your host sets, and been shut down. Or the server itself may be down. Your host can check both.
Two plain questions get the conversation started:
- Is my database running?
- Is it within its limits?
Give them the exact message and the time you first saw it. Those two details help them look in the right place from the start. If you have other sites on the same hosting account, see whether they load too. That’s worth mentioning on the call.
What If the Settings and the Host Both Check Out?
WordPress’s handbook says that once you’ve checked wp-config.php for errors and confirmed with your host that there’s no hosting issue, it’s possible the site has been hacked. That’s the last item on its list. At that point, the next move is to bring in someone who works on WordPress sites.
Stay calm and stick to the facts. Share these four details with them:
- The exact message on the screen
- When it started
- What changed shortly before
- What your host said
Should You Turn On WordPress’s Repair Setting?
WordPress’s handbook describes automatic database repair support, which is turned on by adding a line to wp-config.php. It says to enable it only if needed and to turn it off once the issue is solved. So it’s a setting for a specific moment, not one to leave running.
While the setting is on, a person doesn’t need to be logged in to use it. As WordPress’s wp-config.php page explains, that’s on purpose: the tool is there to repair a corrupted database, and people may be unable to log in when the database is corrupted. That’s why it isn’t something to leave on.
Turning it on and off is a job for your host or a developer. And keep its role clear. The handbook describes the setting, but it doesn’t say the setting fixes this error. Treat it as one tool a professional may reach for.
Back Up Before You Change Anything
WordPress’s handbook says to back up your database before you take any action on it. On a site that’s down, you may not be able to make that copy yourself. In that case, ask your host what copies it keeps.
A backup plan makes moments like this calmer. We’ve laid out what a website backup plan should cover, from what to copy and how regularly to where the copies live and who restores them.
Get a Second Set of Hands for the Next One
Spilt Media’s WordPress support plans handle updates, security, backups, performance optimization, content changes and troubleshooting.
At Spilt Media, we see hosting support and WordPress support as complementary. Your host covers server-level issues, such as a site being down. WordPress support covers the updates, backups and troubleshooting that sit on top.
If you’d like to talk through WordPress support and what to do when your site goes down, you can book a consultation with Spilt Media.
Frequently Asked Questions About the Error Establishing a Database Connection
Does this error mean my site was hacked?
Not necessarily. WordPress’s handbook puts a hacked site last on its list. It comes up only after the wp-config.php settings have been checked and the host has ruled out hosting issues. Work through those first.
Can I fix it without opening wp-config.php?
You may not need to open it. If the database has met its quota or the server is down, the cause sits with your host, and your host is the one to fix it. The handbook’s next step after the configuration check is to contact the host, and you can make that call without touching any files.
Should I leave the repair setting on?
No. WordPress’s handbook says to enable it only if needed and to turn it off once the issue is solved. While it’s on, people can use it without logging in.
Who should I call first, my developer or my host?
If someone looks after your site, tell them first and send your host the exact message too. If nobody does, call your host first. That follows the handbook’s order, since its next step after checking the configuration is to contact the host.