Error Establishing a Database Connection

Error Establishing a Database Connection - MakeWPFast
Critical Frequency: Common
Error message: Error establishing a database connection

‘Error establishing a database connection’ means WordPress cannot connect to your MySQL/MariaDB database. This is one of the most alarming WordPress errors because it makes your entire site inaccessible.

This error is usually caused by incorrect database credentials in wp-config.php, especially after a migration or hosting change. Less commonly, it can indicate that the database server itself is down or overloaded.

Common Causes

  1. Wrong database credentials in wp-config.php (DB_NAME, DB_USER, DB_PASSWORD, DB_HOST)
  2. MySQL/MariaDB service is down or unresponsive
  3. Database server is overloaded (too many connections)
  4. Corrupted database tables
  5. DB_HOST changed after server migration (localhost vs 127.0.0.1 vs socket)

How to Fix It

  1. Verify credentials: Open wp-config.php and check DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST match your hosting panel
  2. Test the database connection: Run mysql -u DB_USER -p DB_NAME from SSH to verify credentials work
  3. Check if MySQL is running: systemctl status mysql or systemctl status mariadb
  4. Repair the database: Add define('WP_ALLOW_REPAIR', true); to wp-config.php, then visit /wp-admin/maint/repair.php
  5. Check DB_HOST: Try 'localhost', '127.0.0.1', or your host's specific database server address
  6. Contact your host if the database server is down u2014 this may be a server-side issue

Diagnosing WordPress errors?

WP Multitool helps you find and fix performance issues, slow queries, and plugin conflicts without guesswork.

Try WP Multitool →
Get WordPress Performance Tips

Plugin reviews, speed optimization guides, and error debugging — straight to your inbox.

No spam. Unsubscribe anytime. We respect your privacy.