WordPress Errors

Error Establishing a Database Connection in WordPress: 5 Fixes

By admin · Nov 26, 2026 · Updated Nov 26, 2026

The message “Error establishing a database connection” means WordPress cannot talk to its database. Without the database, WordPress cannot show your content. Here are the common causes and fixes, from easiest to hardest.

Why does this error happen?

  • Wrong database details in wp-config.php
  • The database server is down or too busy
  • A corrupted database table
  • Your hosting account has reached a limit

Fix 1: Check wp-config.php

Open wp-config.php and check these four lines:

define('DB_NAME', 'your_database');
define('DB_USER', 'your_user');
define('DB_PASSWORD', 'your_password');
define('DB_HOST', 'localhost');

Compare them with the details in your hosting panel under MySQL Databases. One wrong letter will break the connection. If you recently changed the database password, update it here too.

Fix 2: Check the database server

Open phpMyAdmin from your hosting panel. If it does not open, the database server is down. Contact your host. Also check if other sites on the same hosting show the same error.

Fix 3: Repair the database

Add this line to wp-config.php:

define('WP_ALLOW_REPAIR', true);

Then visit yoursite.com/wp-admin/maint/repair.php and click “Repair Database”. When it is done, remove that line. This page can be opened by anyone while the line is there.

Fix 4: Check hosting limits

A traffic spike or a full disk can stop the database. Check your hosting panel for resource or disk usage warnings.

Fix 5: Restore a backup

If nothing works, restore your latest backup from your host or a backup plugin.

FAQs

Is my website deleted?

No. Your data is usually safe in the database. WordPress just cannot reach it right now.

Why does the error show only on wp-admin?

It can mean a corrupted table. Try Fix 3.

Can a plugin cause this error?

Rarely. Wrong login details and server problems are much more common.

What is DB_HOST?

It is the address of your database server. On most hosts it is localhost, but some hosts give a different address.

Need it fixed fast? Contact us.

admin

WordPress developer with 50+ websites built.

About Hire me

Can't fix this yourself?

Hire a WordPress developer. Send us the error and we fix it within 24 hours.

Hire a developer

Free WordPress security checklist

15 simple steps to keep your site safe. Enter your email to get it.

Related fixes

Ready to grow online?

Tell us what you need: a website, SEO, marketing or an AI agent. We reply fast with a clear price and timeline.

© 2026 Avorun. All rights reserved.
Hire an expert