
Seeing the dreaded message “Error Establishing a Database Connection” on your WordPress site can be panic-inducing โ your entire website goes offline and visitors see nothing but a blank page with that one line. The good news: the error establishing a database connection fix is usually straightforward, and most of the time it comes down to one of three things: wrong login details in your configuration file, a corrupted database, or a database server that is down. In this 2026 guide, we will walk you through exactly what causes this error and the seven proven steps to get your site back online fast.
What Causes the “Error Establishing a Database Connection” Error?
WordPress stores all your posts, pages, comments, and settings in a MySQL database. Every time someone visits your site, WordPress connects to that database using login credentials stored in a file called wp-config.php. If that connection fails for any reason, WordPress has nothing to display โ hence the error. The most common causes are:
- Incorrect database credentials in wp-config.php: The database name, username, password, or host (DB_NAME, DB_USER, DB_PASSWORD, DB_HOST) do not match what your hosting account actually uses. This often happens after you change your database password in the hosting panel, move hosts, or restore a site from a backup.
- Corrupted database tables: A failed WordPress update, a plugin conflict, or a server crash can damage database tables so they can no longer be read.
- Database server is down or overloaded: The MySQL server on your hosting plan may be offline, restarting, or overwhelmed by traffic โ especially common on budget shared hosting.
- Corrupted WordPress core files: Missing or damaged core files can break the code that opens the database connection.
- Database user privileges revoked: The database user lost its permissions, so MySQL rejects the login even though the password is right.
- Hosting resource limits hit: Your plan ran out of disk space, memory, or allowed database connections, and the server refuses new ones.
How to Fix “Error Establishing a Database Connection”
Before you touch anything, back up your site โ download a copy of wp-config.php and ask your host to snapshot the database. Then work through these steps in order:
- Check your database credentials in wp-config.php. Open the file via FTP or your hosting file manager and compare the four constants โ
DB_NAME,DB_USER,DB_PASSWORD, andDB_HOSTโ with the values shown in your hosting control panel (usually under “MySQL Databases”). The password is case-sensitive, andDB_HOSTis usuallylocalhost, though some hosts use a custom hostname. Fix any mismatch, save the file, and reload your site. - Verify the database server is running. Log in to your hosting panel and try opening phpMyAdmin. If you cannot reach your database there either, the MySQL server itself is down or your account hit a limit โ this is a hosting-side problem, so contact your host’s support team and ask them to check the server status.
- Repair the database with the built-in tool. Add
define( 'WP_ALLOW_REPAIR', true );just above the “That’s all, stop editing!” line in wp-config.php, then visityourdomain.com/wp-admin/maint/repair.phpand click “Repair Database”. When it finishes, remove that line again โ leaving it enabled is a security risk. For a deeper breakdown of database maintenance, see the guides on the KamiWeb blog.

- Check database user privileges. In your hosting panel’s MySQL section, confirm that your database user is still assigned to the WordPress database with “All Privileges” (or at least SELECT, INSERT, UPDATE, DELETE). Re-assign them if needed.
- Replace corrupted core files. Download a fresh copy of WordPress, then re-upload everything in
wp-adminandwp-includesplus the root files โ but notwp-contentand not your existingwp-config.php. This fixes broken files without touching your content or settings. If you manage themes and plugins regularly, bookmark our free WordPress plugins collection. - Restore from a backup. If the error appeared right after an update, migration, or restore, roll back to a recent working backup of both your files and database. Then re-apply the change more carefully. A reliable backup routine is the single best defense โ check KamiWeb’s free WordPress themes for well-maintained options that reduce update failures.
- Contact your hosting provider. If none of the above works, gather the details: when the error started, the exact message, and what you already tried. Ask support to confirm MySQL is running, check connection limits, and review the server error logs. Most hosts resolve these in under an hour.
Conclusion
The “Error Establishing a Database Connection” looks scary, but it is almost always fixable in under an hour: start with the credentials in wp-config.php, verify the server is up, repair the database, and only then look at core files, backups, and your host. Once your site is live again, protect yourself with regular backups, keep WordPress and plugins updated, and monitor uptime. For more free tools and troubleshooting resources, visit the KamiWeb homepage โ and explore our free online tools to keep your site running smoothly.
