6 min readView as Markdown

Getting "Error Establishing a Database Connection"? Start Here

Seeing “Error Establishing a Database Connection” on your WordPress site? This WordPress database connection error means your site can’t reach the database it needs to load your pages. Your content may still be intact. This SiteWon guide walks you through what to check first, what to tell your host, and how to confirm your site works again.

ST

SiteWon Team

WordPress care editors

Key Takeaways

  • Your content may still be intact. “Error Establishing a Database Connection” means WordPress can’t reach the database it needs to load your site.
  • Check what visitors can access. Open your homepage, an internal page, and /wp-admin/ from another network, then check your host’s status page.
  • Give your host a clear timeline. Share the affected URLs, when the site last worked, when the error appeared, and any recent migrations, password changes, or plugin updates.
  • Verify your backup before making changes. Ask how recent orders or form submissions will be preserved if a restore is needed. Run a database repair only after your host confirms table damage.
  • Test the site after recovery. Open a public page, sign in to WordPress, and verify a key action such as submitting a form or placing a test order on staging.

What does the WordPress error “Establishing a Database Connection” mean?

Think of your website as a storefront and its database as the storeroom. The storefront can still be there, but WordPress needs to get into the storeroom to retrieve pages, settings, and other information. When it can’t get in, visitors may see a database connection error instead of your site.

Illustration of stacked browser windows showing an error screen and a yellow warning sign.

First, check whether it’s just you

  1. Open the site from another device or network. Try your phone on mobile data. Check the homepage and an inside page, and note which URLs show the error.
  2. Open your WordPress dashboard. Add /wp-admin/ to your domain. If the homepage loads but the dashboard fails, the homepage may be showing a saved copy while the dashboard needs a live database connection.
  3. Check your host’s status page. Look for an incident affecting your server or region. If the status page shows everything is operational, your host can still check for a problem specific to your account.

What causes a WordPress database error?

Before you try a fix, note when the error first appeared, which pages it affects, and whether it clears on its own. Those details can help your host narrow down the cause, especially if the site starts working again before they can check it. The WordPress guide to common errors (opens in a new tab) explains how hosting problems and database settings can trigger the same message.

  • Database details changed. After a migration or password reset, WordPress may still be using the old password or trying to reach the previous database server.
  • The database server is unavailable or overloaded. An outage can take the site down entirely. A traffic spike can exhaust available database connections and make the error come and go.
  • The hosting account hit a limit. If a WordPress database error appears alongside a “disk full” warning, ask your host to check available space on the database server and confirm whether your account has reached its storage quota.
  • A recent plugin change may have increased database load. If the error started right after an update, share the plugin name and update time with your host. The timing gives them something specific to investigate.

What you can do without touching code

Contact your host first, especially if the error affects both the public site and the dashboard. Check whether anyone recently moved the site, changed a database password, or updated a plugin. You can send this message through your hosting support portal.

My WordPress site at [your domain] is showing “Error Establishing a Database Connection.” I first saw it at [date, time, and time zone]. It affects [URLs and whether /wp-admin/ works]. The most recent change I know about is [change, or “none known”]. Could you check whether the database service is responding, whether my account hit a storage or connection limit, and whether the database user still has access?

If support suggests a restore, ask what they would restore and when the backup was taken. If you run a store or collect leads, ask how they’ll preserve newer orders or submissions before replacing the live database. If the database server is still down, ask your host to restore the service first.

Technical steps to fix “Error Establishing a Database Connection”

Back up the site before changing any files. Before you try to fix “Error Establishing a Database Connection,” confirm you have a recoverable copy of your WordPress files and database. If the database is unreachable and you can’t export it, ask your host to confirm what backup is available before proceeding.

1. Check the database details in wp-config.php

Open wp-config.php through your host’s file manager or secure file access. Use the official WordPress guide to editing wp-config.php (opens in a new tab) to locate these four settings and compare them with the values your host provides.

SettingWhat to verify
DB_NAMEThe database name for this WordPress installation
DB_USERThe database user assigned to it
DB_PASSWORDThe current password for that database user
DB_HOSTThe database server address specified by your host

Ask the host to confirm the user has access to that database. Keep the password and the full configuration file out of support messages and screenshots.

2. Check logs and investigate recent plugin changes

Start with the host’s PHP and database logs. They can help distinguish a rejected login from a connection timeout or a server that has reached its connection limit. If a developer needs WordPress debug mode, use a staging copy where possible. If they need to troubleshoot on the live site, keep errors off public pages, log them privately, and turn debugging off afterward. The official WordPress debugging guide (opens in a new tab) explains the logging and display settings.

If the database service is healthy and the problem started after a plugin update, test that plugin on staging first. If a live test is necessary, check what the plugin controls before deactivating it. A checkout or forms plugin can interrupt customer activity while it’s disabled.

3. When to repair WordPress database tables

If WordPress connects but reports that certain tables are damaged, ask your host to confirm the issue before running a repair. Once your host confirms the table damage, follow the official instructions for using the WordPress database repair tool (opens in a new tab). Add define( 'WP_ALLOW_REPAIR', true ); to wp-config.php, open /wp-admin/maint/repair.php on your site, and select Repair Database.

Remove the WP_ALLOW_REPAIR line immediately afterward. While it’s enabled, anyone can open the repair page without logging in. If the repair reports failures, save the output for your host.

4. Confirm your site works after the fix

Once the site is back, open a public page and sign in to /wp-admin/. Then test an action your visitors rely on. Submit a test form and confirm the entry or notification arrives. If you run a store, use a staging site with your payment provider’s test mode to place a test order and confirm it appears in the dashboard.

When to call your host or developer?

Stop before making changes if you have no verified backup, the error returns after a repair, or you spot unexpected redirects or unfamiliar administrator accounts. Your host can check database availability and account limits. A developer can investigate repeated table damage, plugin activity, or signs that someone compromised the site. Share the affected URLs, timestamps, and recent changes so they can pick up where you left off.

Get alerted when your WordPress site goes down

If you’re seeing “Error Establishing a Database Connection” now, check your public site and dashboard. Send your host the affected URLs and the time the error started. Once your site is back, set up WordPress site monitoring with SiteWon to get alerted when your site becomes unavailable.

If your website handles orders or brings in leads, explore SiteWon’s website management for small business to see what else you can track from one dashboard.

Sources:

Frequently Asked Questions

About the author

SiteWon Team

WordPress care editors

The SiteWon team writes practical guidance for people who monitor and maintain WordPress sites.

Start monitoringfor free.

Connect a WordPress site and SiteWon watches health, security, performance, updates, and uptime, so the next check starts with what already changed.

SiteWon My Sites dashboard with connected WordPress sites and pending updates