Back to Home
Error Establishing Database Connection: WordPress
wordpress-error

Error Establishing Database Connection

Error Establishing Database Connection: WordPress

20 views
Updated February 28, 2026

Quick Fix

Check wp-config.php for correct DB credentials, ensure MySQL server is running, and clear any corrupted tables. Restart the server and refresh the site.

What it Means

The 'Error Establishing Database Connection' message appears when WordPress cannot connect to its MySQL database. It usually means the credentials in wp-config.php are wrong, the database server is down, or the database file is corrupted.

Possible Causes

  • 1
    Wrong database name, username or password in wp-config.php
  • 2
    MySQL server stopped or unreachable
  • 3
    Corrupted database tables
  • 4
    Insufficient file permissions on wp-config.php
  • 5
    Server resource limits (memory, connections) exceeded

How to Fix

    Step-by-Step Solutions

    1. Verify wp-config.php Credentials

      Open wp-config.php and confirm DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST match your hosting settings. A typo will block the connection.

    2. Check MySQL Service

      On the server, run a status check. If it’s stopped, start it. This ensures the database is listening for connections.

      systemctl status mysql
    3. Repair Database Tables

      Use phpMyAdmin or WP-CLI to run a repair. Corrupted tables often trigger the error.

      wp db repair
    4. Restore from Backup

      If the database is beyond repair, import a recent backup to restore site data.

      wp db import backup.sql

    Commands You Can Try

    mysqladmin -u root -p ping
    wp db check
    wp db optimize

    Technical Details

    Error TypeRuntime
    SeverityMedium
    Platformwordpress-error
    App VersionAll

    Still stuck?

    Pro tips

    • Use WP-CLI for faster database checks
    • Enable debug mode (define('WP_DEBUG', true);) to see detailed errors
    • Set up a staging site to test changes before live
    • Monitor MySQL logs for recurring connection issues

    Contact your hosting provider or a database administrator if you cannot restart MySQL, if you lack SSH access, or if database corruption persists after repair attempts.

    If these solutions didn't help, try searching our database for similar issues.

    Contact Support