WordPress Database Error: 6 PROVEN Fixes That Actually Work (2026)

✍️ By Vikas Rohilla 📅 Updated: March 2026 ⏱️ 9 min read 🏷️ WordPress Errors

One moment your WordPress site is working perfectly. The next, every single visitor — including you — sees this:

“Error establishing a database connection.”

No homepage. No blog posts. No admin dashboard. Just one line of text and a completely inaccessible site.

A WordPress database error is one of the most alarming problems you can encounter — because unlike a plugin conflict or a slow page, it takes your entire site offline instantly. But here is the important thing to understand before you panic: your content is safe. Every post, page, and setting is still sitting in your database exactly where you left it. WordPress simply cannot reach it right now.

This guide covers every cause of a WordPress database error, the exact fixes in the right order, and how to make sure it never brings your site down again.

🚨 Site down right now? Jump straight to Fix 1 — check your wp-config.php database credentials. Wrong credentials cause 70% of all WordPress database errors and take under 5 minutes to verify and correct.
wordpress database error establishing a database connection browser message
The WordPress database error message — “Error establishing a database connection” — takes the entire site offline including the wp-admin dashboard

What Is the WordPress Database Error?

Every WordPress site runs on two separate systems working together: PHP files that handle your site’s logic and templates, and a MySQL database that stores all your content — posts, pages, comments, user accounts, plugin settings, and theme options.

Every time someone visits a page on your site, WordPress runs PHP code that connects to MySQL, pulls the relevant content, and assembles it into the page the visitor sees. When that connection fails, WordPress has nothing to display. The result is a WordPress database error — a blank page with a single error message and a completely inaccessible site.

What makes a WordPress database error particularly disorienting is that it affects both your frontend and your wp-admin simultaneously. You cannot access your dashboard to troubleshoot from inside WordPress — everything has to be fixed via cPanel, File Manager, or phpMyAdmin.

📖 Related: A WordPress database error is different from the WordPress White Screen of Death — which is a PHP error. A database error specifically means the connection between PHP and MySQL failed. The fixes are completely different.

Why Does the WordPress Database Error Happen?

🔴 Wrong DB Credentials

Most common cause — 70% of cases. Wrong database name, username, password, or host in wp-config.php. Happens after migrations or hosting changes.

🔴 Database Server Down

MySQL server crashed or is under maintenance. Your hosting provider’s server issue — nothing wrong with your files.

🟡 Corrupted Database Tables

Tables become corrupted after plugin conflicts, failed updates, or sudden server crashes. WordPress shows “One or more tables unavailable.”

🟡 Too Many Connections

MySQL has a connection limit. Traffic spikes or runaway plugins can exhaust all available connections — causing a temporary database error.

🔵 Corrupted Core Files

Malware infection or failed update corrupted WordPress core files — breaking the PHP-to-MySQL communication layer.

🟢 Wrong Site URL in DB

After a migration, the stored site URL still points to the old domain — causing redirect loops and connection failures.

Quick Diagnosis — Which Type Do You Have?

What You SeeMost Likely CauseFix To Use
Error on frontend + wp-adminWrong credentials or server downFix 1 then Fix 2
Error only on frontend, wp-admin loadsCorrupted database tablesFix 3
“One or more tables unavailable”Corrupted tablesFix 3
Started after migrationWrong credentials or site URLFix 1 then Fix 5
Intermittent — comes and goesToo many connections or traffic spikeFix 4
Started after update or hackCorrupted core filesFix 6

Fix 1: Check Your Database Credentials in wp-config.php

This is the first thing to check for any WordPress database error — and it resolves the problem in 70% of cases. Your database credentials are stored in a file called wp-config.php in your site’s root directory. If any of the four key values are wrong, WordPress cannot connect to the database.

  1. Open Hostinger hPanel → File Manager → public_html
  2. Find wp-config.php → right-click → Edit
  3. Look for these four lines near the top of the file
define( ‘DB_NAME’, ‘your_database_name’ ); define( ‘DB_USER’, ‘your_database_username’ ); define( ‘DB_PASSWORD’, ‘your_database_password’ ); define( ‘DB_HOST’, ‘localhost’ );
wp-config.php file open in cpanel file manager showing database credentials wordpress database error fix
cPanel File Manager → wp-config.php → these four lines contain your database credentials — wrong values here cause the WordPress database error in 70% of cases
📖 Related: Database errors sometimes surface as 500 errors. Read 500 Internal Server Error WordPress Fix — if your database error leads to a full site crash, the 500 error guide covers the complete recovery path.

How to Verify Your Correct Credentials

  1. Go to Hostinger hPanel → MySQL Databases
  2. You will see your database name, username listed there
  3. Compare exactly with what is in wp-config.php — they must match character for character
  4. If the password is wrong — reset it in hPanel → MySQL Databases → change password → update wp-config.php with the new password
  5. Save wp-config.php → refresh your site
hostinger hpanel mysql databases page showing database name username wordpress database error
Hostinger hPanel → MySQL Databases — your correct database name and username are listed here. Compare them exactly with what is in wp-config.php to fix the WordPress database error.
💡 DB_HOST note: On most shared hosting including Hostinger, the correct value is localhost. But on some managed hosting plans, it may be a specific IP address or hostname. If localhost is not working, check your hosting dashboard or contact support for the correct DB_HOST value.
📖 Related: If your site crashes with a fatal error alongside database issues, a low PHP memory limit may be the root cause. Read How to Fix WordPress Memory Limit Exhausted — increase WP_MEMORY_LIMIT in wp-config.php in under 2 minutes.

Fix 2: Check if the Database Server Is Down

If your credentials are correct but you are still seeing the WordPress database error, the MySQL server itself may be down or overloaded. This is a hosting-side issue — nothing you can fix from within WordPress.

  1. Log into Hostinger hPanel
  2. Check for any maintenance notices or server status alerts on the dashboard
  3. Go to hPanel → MySQL Databases → phpMyAdmin — if phpMyAdmin loads and shows your database — the server is running fine and the issue is your credentials
  4. If phpMyAdmin does not load — the MySQL server is down. Contact Hostinger support immediately with your domain name
  5. While waiting — check hostingstatus.com for any reported Hostinger outages
⚠️ Temporary fix while server is down: Enable a maintenance page so visitors see a friendly message instead of a raw database error. Add this to the top of your .htaccess file — it redirects all visitors to a maintenance page while your database is being restored.
📖 Related: If your site went offline during a plugin update, also check whether WordPress is stuck in maintenance mode — both errors can appear simultaneously after an interrupted update.

Fix 3: Repair Corrupted Database Tables

A corrupted database is the second most common cause of a WordPress database error. This happens when database tables get damaged — usually after a plugin conflict, a failed update, or a sudden server crash mid-write. WordPress has a built-in repair tool that fixes this in one click.

Method 1 — WordPress Built-in Repair Tool (Easiest)

  1. Open wp-config.php via cPanel File Manager
  2. Add this line before the /* That’s all, stop editing! */ comment:
define( ‘WP_ALLOW_REPAIR’, true );
  1. Save the file
  2. Visit this URL in your browser: https://yourdomain.com/wp-admin/maint/repair.php
  3. Click Repair Database — WordPress will scan and fix all corrupted tables
  4. After repair is complete — go back to wp-config.php and remove the WP_ALLOW_REPAIR line immediately
  5. Refresh your site — the database error should be resolved
wordpress built-in database repair tool repair.php screen this error fix
WordPress built-in database repair tool — visit /wp-admin/maint/repair.php after adding WP_ALLOW_REPAIR to wp-config.php — fixes corrupted tables causing the the error

Method 2 — phpMyAdmin Repair (More Control)

  1. Go to hPanel → MySQL Databases → phpMyAdmin
  2. Click your WordPress database name in the left sidebar
  3. Click Check All to select all tables
  4. In the dropdown at the bottom — select Repair table
  5. Click Go — phpMyAdmin runs repair on every table
  6. Refresh your site after the repair completes
phpmyadmin repair table option database connection error corrupted tables fix
phpMyAdmin → select all tables → Repair table — fixes corrupted database tables that cause the the issue message

Fix 4: Fix Too Many Database Connections

When too many visitors hit your site simultaneously — or when a plugin opens database connections without properly closing them — MySQL runs out of available connections. Every new request after that point returns a database error until connections free up.

  1. Add this line to wp-config.php to enable error logging and confirm this is the cause:
define( ‘WP_DEBUG’, true ); define( ‘WP_DEBUG_LOG’, true );
  1. Check /wp-content/debug.log — if you see Too many connections — this is confirmed
  2. Go to Plugins → Installed Plugins — deactivate all plugins → test if the error clears
  3. Reactivate plugins one by one — the plugin that causes the error to return is opening unclosed database connections
  4. Contact Hostinger support to temporarily increase your MySQL connection limit if traffic spikes are the cause
  5. Consider upgrading your hosting plan if your site traffic has grown — shared hosting plans have lower MySQL connection limits than Business or Cloud plans

Recurring database errors? Your hosting plan may be the bottleneck.

Hostinger Business and Cloud plans include higher MySQL connection limits, dedicated resources, and priority support — built for growing WordPress sites.

Upgrade Hosting →

Fix 5: Fix this error After Migration

Moving your WordPress site to a new domain or hosting provider is one of the most reliable triggers of a the error. Two things typically go wrong: the database credentials change on the new host, or the site URL stored in the database still points to the old domain.

Step 1 — Update Credentials in wp-config.php

Follow Fix 1 above — verify that the DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST in wp-config.php match the new hosting environment exactly. On a new host, all four values are different from your previous host.

Step 2 — Fix Site URL in wp-config.php

If credentials are correct but the error persists, add these two lines to wp-config.php temporarily:

define( ‘WP_HOME’, ‘https://yournewdomain.com’ ); define( ‘WP_SITEURL’, ‘https://yournewdomain.com’ );

Replace yournewdomain.com with your actual domain. Once your site loads — go to Settings → General and update both URL fields there permanently. Then remove these two lines from wp-config.php.

📖 Related: After fixing a migration-related database connection error, run a full technical audit to confirm everything transferred correctly — Complete Technical SEO Audit Guide covers all the post-migration checks.

Fix 6: Replace Corrupted WordPress Core Files

In rare cases — after a malware infection or a badly failed update — the WordPress core files themselves become corrupted, breaking the connection between WordPress and the database. The fix is to replace the core files with a fresh copy without touching your content.

  1. Download the latest WordPress version from wordpress.org/download/
  2. Unzip the downloaded file on your computer
  3. Delete the wp-content folder from the unzipped files — this protects your themes, plugins, and uploads
  4. Delete the wp-config.php file from the unzipped files — this protects your database credentials
  5. Upload the remaining files to your public_html via cPanel File Manager → overwrite existing files when prompted
  6. Refresh your site — fresh core files should resolve the this issue
⚠️ Important: Only replace wp-admin and wp-includes folders. Never overwrite wp-content or wp-config.php — these contain your actual content, themes, plugins, and database credentials. Deleting them from the fresh download before uploading is the critical step.
📖 Also useful: Want to know exactly what theme and plugins are running on your site before making database changes? Use the free WordPress Theme & Plugin Analyzer — confirms your full technical stack in one scan. Also check Content to Code Ratio and PageSpeed Insights Guide after recovery.
📖 Related: After fixing a database error, if wp-admin login keeps looping, you may also have a WordPress login redirect loop — regenerating security keys in wp-config.php fixes both issues simultaneously.

How to Prevent the issues

  • Daily automated backups: UpdraftPlus free tier backs up your database to Google Drive daily. A database backup is your fastest recovery option for any database error — restore takes minutes instead of hours of manual troubleshooting.
  • Never edit wp-config.php without a backup: Any manual edit to wp-config.php that introduces a typo in your database credentials instantly triggers a database error. Always keep a copy of your current working wp-config.php before making any changes.
  • Update plugins one at a time: Bulk plugin updates occasionally cause database table conflicts. Update one plugin at a time, testing your site after each update — the moment a database error appears, you know exactly which plugin caused it.
  • Check Core Web Vitals after recovery: A database error can temporarily impact your site’s performance signals. Read Fix INP in WordPress and Fix LCP in WordPress to restore your scores after fixing the error.
  • Install WP-Optimize: This free plugin cleans your database — removing post revisions, spam comments, transients, and orphaned data that accumulate over time and increase corruption risk. Run it monthly.
  • Monitor database size: hPanel → MySQL Databases shows your database size. A rapidly growing database on a shared hosting plan can hit resource limits and trigger connection errors. Clean regularly and upgrade hosting if needed.
📖 Related: Database errors and site hacks often go hand in hand — malware is a common cause of core file corruption. Read WordPress Site Hacked — Signs & Recovery Guide to protect your site from the security issues that lead to database errors.
🔍

ToolXray Free WordPress Technical Audit

After fixing a database error — confirm no performance or SEO damage remains. Core Web Vitals, PageSpeed, TTFB and 80+ checks. Free, no signup.

Run Free Audit →

The Bottom Line

A this error is one of the most alarming WordPress problems — but it is almost always caused by one of a small number of fixable issues. Start with Fix 1: verify your database credentials in wp-config.php. This single step resolves the vast majority of the errors within minutes.

If credentials are correct, check whether the MySQL server is down, repair any corrupted tables using WordPress’s built-in repair tool, and work through the remaining fixes in order. Between these six fixes, virtually every database connection error is recoverable without data loss.

The real lesson from any database error is preparation: daily automated backups, careful plugin update practices, and regular database cleaning reduce both the frequency and the recovery time of any future database issues significantly.

🔍 Free WordPress Technical Audit

After fixing your database error — check Core Web Vitals, PageSpeed, broken links and 80+ signals

Run Free Audit at ToolXray →

Related Articles

💀

WordPress White Screen of Death

Different from a database error — WSOD is a PHP crash. 9 fixes that work.

🔴

WordPress 404 Error Fix

Pages returning “not found” after a migration or database fix? 7 proven solutions.

🚨

WordPress Site Hacked Guide

Malware is a common cause of database corruption. Signs + complete recovery steps.

🚀

WordPress Speed Optimization

After fixing your database — optimize for PageSpeed 90+ scores.

🔬

Complete Technical SEO Audit

Post-database error audit — check crawlability, indexing and all 80+ signals.

⏱️

Why TTFB Is Critical in 2026

Database errors spike your TTFB — here’s how to monitor and fix it.

🆓

Free Alternative to Ahrefs

Monitor your site’s recovery with free SEO tools — no expensive subscription needed.

Frequently Asked Questions

❓ What causes the this issue?
The most common cause of a the issue is incorrect database credentials in wp-config.php — wrong database name, username, password, or host. This accounts for around 70% of cases. Other causes include a crashed MySQL server, corrupted database tables, too many simultaneous connections, corrupted WordPress core files, or a wrong site URL after a domain migration.
❓ Will I lose my content if I get a database error?
No — a this error does not delete your content. All your posts, pages, settings, and user data remain safely stored in the MySQL database. The error simply means WordPress cannot connect to the database to retrieve that content. Once the connection is restored using the fixes above, everything comes back exactly as it was.
❓ How do I fix a the error without access to wp-admin?
Since a database connection error blocks wp-admin access, all fixes are done via cPanel File Manager and phpMyAdmin. Open wp-config.php in File Manager to check credentials. Use phpMyAdmin to repair corrupted tables. Use the WordPress repair URL (/wp-admin/maint/repair.php) after adding WP_ALLOW_REPAIR to wp-config.php. None of these steps require wp-admin access.
❓ What is the difference between this issue and White Screen of Death?
A the issue specifically means the connection between WordPress’s PHP code and its MySQL database failed — the error message “Error establishing a database connection” appears. The White Screen of Death is a PHP fatal error that crashes before WordPress can display anything — it shows a completely blank white page with no text. Both take the site offline but have completely different causes and fixes. Database errors are fixed via wp-config.php and phpMyAdmin. White screen errors are fixed by disabling plugins or fixing PHP memory limits.
❓ How long does a database error take to fix?
If the cause is wrong credentials in wp-config.php — under 5 minutes once you have the correct values from your hosting dashboard. If the cause is corrupted database tables — the built-in repair tool typically completes in under 2 minutes. If the MySQL server is down due to a hosting provider issue — recovery time depends entirely on your host, typically 15 minutes to a few hours. Having daily backups reduces any this error to a maximum 30-minute restore regardless of the cause.

    Leave a Comment

    Your email address will not be published. Required fields are marked *

    Scroll to Top