Home / WordPress / Error Establishing a Database Connection in WordPress: Fix

Error Establishing a Database Connection in WordPress: Fix

Fix the WordPress database connection error by verifying wp-config.php credentials, database server status, and repairing tables.

Views: 25 Unique: 19 Updated: 2026-03-18

What this problem is

WordPress shows: Error establishing a database connection.

Why it happens

  • Incorrect DB credentials in wp-config.php
  • Database server is down or overloaded
  • Corrupted database tables
  • Exceeded database user limits

Prerequisites

  • Access to wp-config.php
  • Hosting panel access (MySQL status, phpMyAdmin)

Diagnosis

  1. Verify DB_NAME, DB_USER, DB_PASSWORD, DB_HOST.
  2. Check if the database server is up in the hosting panel.
  3. Try logging into phpMyAdmin with the same credentials.

Detailed steps

Step 1) Fix credentials in wp-config.php

Update values to match hosting database user and password.

Step 2) Check DB host value

Some hosts require a specific DB_HOST (not always localhost).

Step 3) Repair the database (if tables are corrupted)

Use the dedicated database repair method if needed.

Expected results

  • Site loads normally and DB connection is stable

What to do if it fails

  • Contact hosting to confirm MySQL service health and whether your account hits limits

Best practices

  • Keep backups and monitor DB resources on high-traffic sites
Back to category