How to Fix “Error Establishing a Database Connection” in WordPress

If your WordPress site shows “Error Establishing a Database Connection,” don’t panic. It just means your website can’t talk to the database properly. This is one of the most common WordPress errors.

In this post, you’ll learn what this error means, why it happens, and how to fix it — even if you’re a beginner.

📌 What Does This Error Mean?

WordPress stores everything — your posts, users, settings — in a database. When it can’t connect to that database, it shows this error.

🚨 Common Reasons for the Error

  • Wrong database login info
  • Database server is down
  • Corrupt WordPress files
  • Too much traffic crashing the server
  • Web hosting issues

🔧 How to Fix “Error Establishing a Database Connection”

Follow this table for step-by-step help:

StepActionWhy It Helps
1Check wp-config.php fileEnsures database name, username, and password are correct
2Contact your web hostThey can tell you if the database server is down
3Repair the databaseFixes corrupt database tables
4Disable plugins and themesRules out plugin or theme issues
5Upgrade your hosting planFixes the error if caused by traffic overload

🛠️ How to Check Database Settings in wp-config.php

  1. Connect to your site via FTP or File Manager
  2. Open the wp-config.php file
  3. Look for the following lines:
define('DB_NAME', 'your_database_name');
define('DB_USER', 'your_username');
define('DB_PASSWORD', 'your_password');
define('DB_HOST', 'localhost');

Make sure they match your hosting database details.

📖 WordPress.org: Editing wp-config.php

🧹 How to Repair the Database

Add this line to your wp-config.php file just before /* That's all, stop editing! */:

define('WP_ALLOW_REPAIR', true);

Then visit:

https://yoursite.com/wp-admin/maint/repair.php

Follow the instructions to repair your database.

🔌 Try Disabling All Plugins

If a plugin is causing the issue:

  • Rename the plugins folder using FTP or File Manager
  • This will deactivate all plugins at once
  • If your site works again, rename the folder back and activate plugins one by one

🔗 Internal Resources from Gbcodies

🌐 Helpful External Resources

💡 Final Thoughts

Don’t let this error scare you. Most of the time, it’s a small mistake like a wrong password or a busy server. Just go step-by-step, and you’ll be back online soon!

Scroll to Top