11 WordPress ServicesView all
8 industry verticalsAll industries
12 UK locationsAll locations
Home/Blog/Troubleshooting
Troubleshooting13 November 2026· 6 min read

"Error Establishing a Database Connection" in WordPress: What It Means and How to Fix It

"Error establishing a database connection" is one of the most alarming WordPress errors — your whole site disappears. Here's how to diagnose it quickly and get back online.

"Error establishing a database connection." Your entire WordPress site disappears — both the front end and the admin dashboard — and visitors see nothing but this error. It sounds catastrophic. In most cases, it's fixable in under 15 minutes.

What this error actually means

WordPress stores all your content, settings and user data in a MySQL database. When WordPress can't connect to that database, it can't render any pages — hence the complete site outage. The error means one of four things: the database credentials in wp-config.php are wrong, the MySQL database server has crashed, the database itself is corrupted, or your hosting server has an underlying issue.

Step 1: Check if it's a hosting server issue

Before touching any files, check whether your hosting provider is having an outage. Go to your host's status page (most have one at status.hostname.com or on their Twitter). If their MySQL service is down, the fix is waiting for them to restore it — there's nothing to do on your end. This accounts for a significant proportion of these errors, especially on shared hosting.

WordPress maintenance plans — proactive monitoring, never miss an outage →

Step 2: Verify your database credentials

Connect to your server via FTP or your hosting's file manager and open wp-config.php. Check these four values:

  • →DB_NAME — the name of your WordPress database
  • →DB_USER — the database username
  • →DB_PASSWORD — the database user's password
  • →DB_HOST — usually "localhost" but can vary (some hosts use an IP or a named host)

Compare these values against your hosting control panel (cPanel → MySQL Databases, or the Databases section of your hosting dashboard). If the credentials don't match — a common cause after a hosting migration or database password reset — update wp-config.php with the correct values.

Step 3: Repair the database

If credentials are correct but the error persists, your database tables may be corrupted. WordPress has a built-in repair tool. Add this line temporarily to wp-config.php:

define('WP_ALLOW_REPAIR', true);

Then visit yoursite.com/wp-admin/maint/repair.php in your browser and click "Repair and Optimize Database". Once the repair completes, remove the WP_ALLOW_REPAIR line from wp-config.php immediately — leaving it in place allows anyone to run the repair tool without authentication.

Step 4: Check your MySQL server via phpMyAdmin

If you can access your hosting control panel, open phpMyAdmin and try to connect to your database directly. If phpMyAdmin can't connect, the MySQL server itself is down — contact your host. If phpMyAdmin connects but your WordPress database shows tables marked as "in use" or "crashed," select all tables, choose "Repair table" from the drop-down and run the repair.

Step 5: Restore from backup

If the database can't be repaired, you need a clean backup. Most managed WordPress hosts (Kinsta, WP Engine, Cloudways) take automated daily backups that you can restore with one click from the hosting dashboard. For shared hosting, check your cPanel for a backup tool or contact support. This is why having an active backup system is non-negotiable — without a recent backup, a corrupted database can mean permanent data loss.

ImportantIf you're seeing this error only on the wp-admin dashboard but the front end of your site works, the problem is likely your wp-admin URL specifically (possibly a caching issue or a wp-config.php directive affecting the admin). Try accessing yoursite.com/?p=1 — if that loads, your database is fine and the issue is specific to the admin path.

Frequently asked questions

What does "Error establishing a database connection" mean in WordPress?+

WordPress cannot connect to your MySQL database. This is caused by one of four things: the database credentials in wp-config.php do not match the actual database (most common after a hosting migration or password reset), the MySQL server on your hosting has crashed, the database itself is corrupted, or your hosting server has an infrastructure issue.

How do I fix WordPress "Error establishing a database connection"?+

First check your hosting provider's status page for outages. If no outage, open wp-config.php via FTP and verify DB_NAME, DB_USER, DB_PASSWORD and DB_HOST match exactly what is in your hosting control panel. If credentials are correct, try the WordPress database repair tool at yoursite.com/wp-admin/maint/repair.php?repair=1.

Does a WordPress database connection error mean I have lost my content?+

No. A connection error means WordPress cannot reach the database — not that the data is gone. All posts, pages, settings and user accounts still exist intact in the database. Once the connection issue is resolved, everything will appear exactly as before.

Why am I only getting the database error on wp-admin but the front end loads fine?+

If the front end loads but wp-admin shows the error, the database is accessible but something is specific to the admin path — often a caching issue or a wp-config.php constant affecting admin requests. Try accessing yoursite.com/?p=1 to confirm the database is working, then investigate admin-specific configuration.

Related service

Database errors during routine updates are a sign your site needs proactive maintenance. Our care plans include staged updates and immediate support for critical errors like this.

WordPress Maintenance Plans →

Next article

Performance

Why Is the WordPress Admin Dashboard So Slow?

→
← All articles