WordPress Error Establishing a Database Connection

Share
Workaround available Self-hosted WordPress (WordPress.org) Updated November 13, 2026Based on 4 user reportsHow we research

Quick answer

This error means WordPress cannot talk to MySQL. Check the database credentials in wp-config.php first, then check with your host for a downed database server or a full quota.

Most likely fix: Check wp-config.php credentials

How to fix it

Try these in order — the most common fix is first.

  1. 1. Check wp-config.php credentials

    1. Open wp-config.php over FTP or the file manager.
    2. Compare DB_NAME, DB_USER, DB_PASSWORD and DB_HOST with the values in your hosting panel's MySQL section. DB_HOST is not always 'localhost' on managed hosts.
    3. Save and reload.
    Did this fix it?
  2. 2. Ask your host about the database server

    1. Check your host's status page and open a ticket asking whether MySQL is running and whether your account has hit its database quota or connection limit.
    2. This is the most common fix on shared hosting after a traffic spike.
    Did this fix it?
  3. 3. Repair the database

    1. Add define('WP_ALLOW_REPAIR', true); to wp-config.php.
    2. Visit yoursite.com/wp-admin/maint/repair.php and click Repair Database.
    3. Remove the line afterwards because the repair page needs no login.
    Did this fix it?
  4. 4. Reset the database password

    1. In your host's panel, set a new password for the database user, then put the same password in wp-config.php.
    Did this fix it?
  5. 5. Scan for compromise

    1. If credentials are correct and the host reports no problem, scan the site (for example with Sucuri SiteCheck) and restore from a clean backup if it is infected.
    Did this fix it?

Symptoms

Every page, front end and wp-admin, shows 'Error establishing a database connection' in plain text.

Why it happens

  • Wrong DB_NAME, DB_USER, DB_PASSWORD or DB_HOST in wp-config.php
  • The MySQL server is down or overloaded
  • The database user lost its privileges, or the password was changed
  • Host database quota full
  • Corrupted database tables
  • A hacked site

This guide also covers

  • error establishing a database connection
  • wordpress database connection error
  • wordpress error establishing database connection fix

Still not working?

If WordPress keeps failing, you're not alone. See every WordPress problem users report or the alternatives people switch to.

Done fighting WordPress? Our small team builds your own WordPress alternative, made for how you work. On your domain or hosted by us. Price agreed together.

Get a quote
Fixed it? Share this guide

The same problem in other apps

All not loading, error messages & connection guides →

Other WordPress errors

All 11 WordPress errors and fixes →