"Error establishing a database connection" is one of the most alarming messages a website owner can see, mostly because it replaces the entire site with a blank page and a single unhelpful line. It looks like everything is gone. It usually is not. WordPress stores your posts, pages, settings and user accounts in a MySQL database, and every page load involves asking that database for content. This message means the request to talk to the database failed, not that the database itself was deleted.

What WordPress is actually trying to do

Every time a visitor loads a page, WordPress reads a file called wp-config.php to find the database name, username, password and host, then uses those details to open a connection to MySQL. If that connection succeeds, WordPress pulls the content it needs and builds the page. If it fails at any point in that handshake, WordPress has no fallback content to show, so it displays this generic error instead of a half-built page.

That single message covers several distinct failure points: wrong credentials, a database server that is not responding, a corrupted database, or a server that is too overloaded to accept new connections. Treating all four the same way wastes time, so the first job is narrowing down which one you are actually dealing with.

Start by checking whether it's just you

Load the site from a different device or network, or use an online "is it down for everyone" checker. If the site is up for other visitors, the problem may be local caching or DNS on your end rather than the database. If it is down for everyone, move on to checking the admin area specifically: try loading yourdomain.com/wp-admin. If the admin login screen shows the same database error, the problem sits below WordPress, at the database or server level, and no plugin or theme setting caused it.

The most common causes, in order of likelihood

  • Incorrect database credentials in wp-config.php, often after a migration, a manual edit, or a restored backup that used a different database name.
  • A database server that has crashed or is not accepting connections, which is a server-side issue rather than a WordPress issue.
  • The hosting account or database has hit a resource limit, such as the maximum number of simultaneous connections, common during a traffic spike.
  • A corrupted database table, sometimes caused by an interrupted import, a bad plugin update, or an abrupt server restart.
  • The database server hostname changed, which happens occasionally after a migration between servers or hosting plans.

Checking wp-config.php credentials

Connect to your site over SFTP or use your hosting control panel's file manager and open wp-config.php in the site's root folder. Confirm that DB_NAME, DB_USER, DB_PASSWORD and DB_HOST match what your hosting control panel actually has on record for that database. A single mistyped character, an extra space, or a credential that was rotated after a security incident is enough to break the connection. If you recently restored a backup or moved hosting providers, this mismatch is the single most common cause.

Checking whether the database server itself is healthy

If credentials check out, the database service on the server may be down, restarting, or refusing new connections because it has reached a connection limit. This is common on shared hosting during unusually heavy traffic, when many visitors and background processes are all requesting data at once. There is not much a site owner can do to fix the server side directly beyond confirming the problem exists and reporting it, but hosting support can check the database process status, current connection counts and any resource limits tied to your plan.

Repairing a corrupted database

WordPress has a built-in repair tool that can fix common table corruption without a full restore. Add this line to wp-config.php, above the line that says "That's all, stop editing":

define('WP_ALLOW_REPAIR', true);

Then visit yourdomain.com/wp-admin/maint/repair.php in a browser. This page is not linked from anywhere and is not password protected while the constant is active, so remove the line from wp-config.php again as soon as the repair finishes. The tool will scan and attempt to repair database tables, and it is worth trying before resorting to a full backup restore, since it can resolve the issue without losing recent content.

When a restore is the faster path

If the repair tool cannot fix the tables, or if the corruption is severe enough that pages return partial or garbled content instead of the flat error message, restoring the database from a recent backup is usually faster than trying to hand-fix individual tables. This is one of the clearest cases where having automated backups pays off: a same-day restore point turns a stressful outage into a short interruption instead of a data-loss event.

What to send to hosting support

If you cannot resolve the error yourself, contact support with specifics rather than just "the site is down." Note the exact time the error started, whether it affects both the front end and wp-admin, whether you made any recent changes such as a plugin update, migration or backup restore, and whether the error message text has changed at any point. That context lets a support engineer check server logs and database status directly instead of starting from zero.

Reducing the odds of it happening again

Most recurring database connection errors trace back to either an under-resourced hosting plan being pushed past its database connection limits during traffic spikes, or a manual process, like a migration or restore, that leaves wp-config.php out of sync with the actual database. Keeping a recent, verified backup, avoiding manual edits to database credentials outside of a planned change, and hosting on a plan sized for your actual traffic and plugin load all reduce how often this error shows up in the first place. ScaleToCloud's WordPress-optimized plans size database resources to expected traffic so a normal spike does not turn into a connection failure.

Choose hosting that fits the site.

Compare the shared hosting plans or explore the separate WordPress optimized range.

Shared hostingWordPress hosting