Few WordPress errors are as alarming as seeing “Error Establishing a Database Connection” where your website should be. This message means WordPress is trying to connect to its MySQL database and failing. Since everything on your site, every page, every post, every setting, lives in that database, nothing can load without it.
The good news is that in most cases, this error has a straightforward cause and a clear fix. Let’s walk through it.
What This Error Actually Means
WordPress stores all your content in a MySQL database. Every time someone visits your site, WordPress connects to that database, retrieves the relevant content, and builds the page. The “Error Establishing a Database Connection” message appears when that connection fails.
It’s important to understand that this error doesn’t necessarily mean your data is lost. In most cases, the database is fine. WordPress just can’t reach it. Think of it like not being able to get into your office because the key doesn’t work. Your files are still inside; you just can’t access them at the moment.
Common Causes
Wrong Database Credentials in wp-config.php
This is the most common cause, especially after a hosting migration or if someone has been editing the wp-config.php file. WordPress needs four pieces of information to connect to its database: the database name, database username, database password, and database host. If any one of these is wrong, the connection fails.
Corrupted Database
Databases can become corrupted after a server crash, a failed update, or if your hosting runs out of disk space while the database is being written to. When tables are corrupted, WordPress may not be able to read them even though the connection itself works.
Database Server Is Down
On shared hosting, your database might run on a different server than your website files. If that database server goes down or becomes overloaded, WordPress can’t connect. This is a hosting-level issue and is out of your direct control.
Hosting Resource Limits Reached
Budget hosting plans set strict limits on database connections. If your site gets a traffic spike, or if a misbehaving plugin opens too many database connections, you can hit these limits. When the limit is reached, new connections are refused, and WordPress shows the error.
Step-by-Step: Fixing the Error
Step 1: Verify Your Database Credentials
Connect to your site via FTP or your hosting file manager. Open the wp-config.php file in the root directory. Look for these four lines:
DB_NAME— the name of your databaseDB_USER— your database usernameDB_PASSWORD— your database passwordDB_HOST— usually “localhost” but can vary by host
Log into your hosting control panel and check these values against what’s actually configured. Pay particular attention to the database host. Most hosts use “localhost” but some, like certain configurations at larger providers, use a specific hostname or IP address. If any of these values don’t match, correct them, save the file, and check your site.
Step 2: Test the Database Connection
If the credentials look correct, test whether the database itself is reachable. Most hosting control panels include phpMyAdmin or a similar database management tool. Try to open your database there. If you can see your tables, the database is working and the problem is in the connection from WordPress.
If phpMyAdmin won’t connect either, the database server itself may be down. Contact your hosting provider.
Step 3: Repair the Database
WordPress has a built-in database repair tool. To enable it, add the following line to your wp-config.php file:
define('WP_ALLOW_REPAIR', true);
Then navigate to yourdomain.ie/wp-admin/maint/repair.php in your browser. You’ll see two options: Repair Database and Repair and Optimise Database. Try “Repair and Optimise Database” first, as it fixes corrupted tables and cleans up inefficiencies at the same time.
Important: Remove the WP_ALLOW_REPAIR line from wp-config.php once you’re done. This page doesn’t require a login, so leaving it enabled is a security risk.
Step 4: Check With Your Hosting Provider
If none of the above steps resolve the issue, the problem is likely at the hosting level. Common hosting-level causes include:
- The database server is experiencing downtime or high load
- Your account has exceeded its database connection limit
- Disk space is full, preventing the database from operating
- Your hosting account has been suspended
Contact your hosting provider’s support team with the details of what you’ve already tried. They can check server-side logs and configuration that you don’t have access to.
When It’s a Simple Fix vs Something Serious
In most cases, this error falls into the “simple fix” category. Wrong credentials after a migration, a database that needs a quick repair, or a temporary server hiccup. These are usually resolved within minutes once the cause is identified.
It becomes more serious when the database is severely corrupted, when there has been data loss due to disk failure, or when the error is a symptom of a broader hosting problem. In these situations, having a recent backup becomes critically important.
If you’re seeing this error and you’re not sure what to do, or if you’ve tried the steps above and it’s still not working, reach out to us. We’ll diagnose the issue and get your site back up and running.

Leave a Reply