Skip to article content

Error establishing a database connection in WordPress: what it means and what to check first

WordPress showing “Error establishing a database connection”? Learn what to check first and what your hosting provider or person who maintains the website needs to investigate it.

What the message really means

When you open your site and instead of the usual content you get a near-blank page with the sentence «Error establishing a database connection», WordPress is telling you something specific: the PHP running your site tried to talk to the database server and did not get a valid answer back. The official WordPress documentation on common errors lists this case as one of the most frequent.

WordPress needs a database to read content, settings and accounts. This message appears when it cannot use the connection it expects. Access details, the server or a reached limit can be involved; the message alone does not identify the cause.

The technical team can obtain more detail from private server or WordPress logs. You do not need to display those errors to visitors or reinstall the site to start investigating. Save the exact message and the time it appeared.

Before you touch anything: check and preserve

Before changing passwords or files, gather a few clues and contact whoever maintains your website. Several simultaneous changes make the cause harder to identify. Start with these checks:

  • Check whether the message also appears in another window or device. Record any difference: a cached page may look normal even while the database connection is failing.
  • Try /wp-admin/. The admin panel sometimes returns a different message («One or more database tables are unavailable») that points you better than the home page.
  • If you manage other sites on the same hosting, check whether they also fail. Several affected sites are useful information for support, not proof that they all have the same cause.
  • Take a screenshot of the message with date and time. If you later need to talk to the host or to whoever maintains the site, it saves back-and-forth.
  • If wp-config.php needs editing, the team should first keep a protected copy outside the website’s public directory. It contains credentials: do not leave a .before or .bak copy in a downloadable folder or include it in screenshots.

The message, timing and recent changes help support direct the investigation. Do not share passwords when asking for help; any access required should be agreed through a secure channel.

WordPress not connecting versus database server down

With the screenshot taken and wp-config.php safe, separate two scenarios that look the same from the outside but call for opposite routes:

  • Scenario 1: the database is alive, WordPress cannot find it. The MySQL or MariaDB server responds normally to other tools, but your WordPress fails to authenticate. The cause is usually in wp-config.php: outdated credentials, a host (DB_HOST) different from what the hosting expects, or revoked grants.
  • Scenario 2: the database server is not answering. It is down, overloaded, in a maintenance window or rejecting connections. There is nothing to change in WordPress; the fix is on the hosting side.

The hosting database manager, such as phpMyAdmin, can provide a clue. Access there does not prove that WordPress uses the same account, server or connection; a failure in that tool alone does not prove the database is down either. Ask support to check the connection used by this particular installation.

Two more clues. Check the service status in the hosting panel; large incidents are usually posted there before support gets flooded. And see whether there has been a recent migration: when a site moves to a new provider, it is common for the database name, user or host to change and for wp-config.php to be left pointing at the old one.

Common causes for a small business site

On small business sites the list of causes tends to repeat itself. Knowing them helps you decide where to look first:

  • Outdated credentials in wp-config.php. Someone changed the database user password from the hosting panel and nobody propagated it to the config file. The error shows up when the site tries to reconnect.
  • DB_HOST that does not match. Most hosts use localhost, but some require a specific IP, an internal domain or a Unix socket. The official reference for editing wp-config.php explains what values it accepts.
  • Corrupt tables after a power cut or hard reboot. The server accepts the connection, but reading a key table (like wp_options) returns an error.
  • Max connections limit reached. When the cap fills up, new attempts get the «Too many connections» error, documented in the MariaDB knowledge base. Common on shared hosting with spikes or a plugin that opens many queries.
  • Traffic or bot spike saturating the server. It does not have to be an attack; a crawler and a newsletter delivery can hit at the same time.
  • A newly activated plugin running heavy queries. If you installed something in the last 48 hours, put it on the suspect list.
  • Failed PHP or MySQL/MariaDB upgrade. When the hosting migrates to a new version and your site is not compatible, the driver may stop talking to the database.
  • Full disk quota. The server cannot write and starts returning intermittent errors.

You will not know the real cause until you look, but this list shapes the first questions: was anything changed? was anything installed? is the host reporting an incident? is the traffic unusual?

A reasonable review order

These checks help narrow the problem without changing several components at once:

  1. Check the hosting service status. Keep the notices and ask whether the database service or any account limit is affected.
  2. Explain what changed before the error. A migration, password change or update can guide the investigation without proving the cause.
  3. Ask the team to check the connection details. They can compare DB_NAME, DB_USER, DB_PASSWORD and DB_HOST with the actual configuration. Do not paste their values into an email or forum.
  4. Request the specific technical error. An access-denied message, connection limit or damaged-table report guides the next check. If debug logs are needed, the team should keep them private and avoid displaying errors to visitors. WordPress’s debugging documentation explains the options.
  5. Test after each correction. Check the public site and administration access, then record what changed and the result.

Options to bring the site back

With the cause narrowed down, the way out depends on the damage. Three common routes and how to pick between them:

When each route fits
RouteWhen it fitsWhat to check afterwards
Fix credentials in wp-config.phpThe error is access related: wrong user or password, wrong host, recent migration. phpMyAdmin responds normally.The site is back; /wp-admin/ signs in; the new values are saved in a secure manager so the issue does not repeat.
Repair tables from phpMyAdmin or with WP_ALLOW_REPAIRThe team confirms table damage and has a protected backup. The method depends on the database engine; WordPress’s repair tool is not suitable for every fault and its page may be accessible without signing in while enabled.The repair finishes without errors; you read the per-table notices; you remove the constant once used; the site answers normally.
Restore the database from a recent backupThe team confirms that restoring is appropriate and has a verified backup. Before restoring it, preserve the current state and assess which recent data is missing from that backup.The restore loads without errors; you verify key entries (last orders, last comments, last posts) to measure the loss; you note the window of unrecovered data.

The rule to remember: do not pick the most aggressive route while the cause is still unclear. Reinstalling WordPress or rebuilding the database «just to try» when the problem is on the hosting side only adds a second incident on top of the first. Where a route is not yet clear, confirm you have a recent and recoverable backup before any irreversible change.

When to ask the host and when to ask whoever maintains the website

An important part of solving this error is knowing who to ask. Mixing up responsibilities costs hours writing to the wrong party:

  • The hosting owns the database server (up or down), the connection limits, the disk quotas, the planned maintenance windows and the installed version of MySQL or MariaDB.
  • Whoever maintains the website (internal or external) owns wp-config.php, the installed plugins, the active theme, scheduled tasks and whichever backups they manage themselves.

If you do not have someone who maintains the website, ask hosting support to confirm the service status and connection requirements first. Some providers also review WordPress configuration and others do not; it depends on your support agreement. Whoever maintains the website and hosting team may need to coordinate their checks.

If the host confirms everything is operational and the error persists, that is when the task enters WordPress territory. There is no sense in touching the database blindly while the cause lives outside it.

Reducing the chance of a repeat

A resolved incident should not be closed cold. These are the measures that tend to pay off once you have the service back:

  • Keep a recent and verified backup. It is not enough for the host to say backups exist; it is worth checking that the backup actually restores before you really need it.
  • Raise the connection limit only when the site's pattern justifies it. Raising it without investigating may hide the cause or increase resource use. Look at what is consuming first, change it afterwards.
  • Watch the wp_options table. Options flagged as autoload load on every request; a table bloated by old plugins makes the server more fragile under spikes.
  • Review components when measurements point to them. The team can investigate expensive database queries or tasks that coincide with the failure. Plugin count or feature type alone does not identify the cause.
  • Store wp-config.php credentials in a secure manager. Not in email and not in an uncontrolled shared document.
  • Subscribe to hosting status notifications. Finding out before a customer writes you improves how you handle it.

None of this guarantees the error will not come back: a hosting incident or a failed upgrade can happen even when you do everything right. What does change is that the next error finds you with the map in hand and not with the lights off. If you are weighing whether your current provider is giving you the service you need, deciding whether to change hosting is a separate conversation, but one connected to this kind of incident.

If you want us to walk you through it

If you can see this error and are unsure what to do next, tell us what you are seeing. You do not need to know the cause before contacting us. A screenshot and a description of what you have already tried will help us suggest a next step and explain whether a technical review would be useful.

If the problem keeps returning, we can assess which performance review your website needs. Scope and access are agreed before work begins; corrections or ongoing maintenance are arranged separately. To distinguish this message from other failures, see the guide to error 500 and WordPress’s critical error message.