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

> Canonical: https://jethost.com/kb/error-establishing-a-database-connection-wordpress/ · Last modified: 2026-10-31T13:35:49+00:00

“Error establishing a database connection” means WordPress loaded but could not reach its database, so it has no content to show. The page goes blank except for that line. The cause is almost always wrong database details, a database that is down or out of resources, or corrupted tables. This guide shows how to find which one it is and fix it.

## What the error means

WordPress keeps your posts, pages, users, and settings in a MySQL database. On every visit it logs in to that database and pulls the content. When the login fails or the database does not answer, WordPress stops and shows this message instead of your site. Your files are fine; the link to the data is the problem.

## Check the database details in wp-config.php

Wrong credentials are the most common cause, especially right after a move or a password change. Open `wp-config.php` in the File Manager or over FTP and check these four lines against your real database:

- `DB_NAME` – the database name
- `DB_USER` – the database user
- `DB_PASSWORD` – that user’s password
- `DB_HOST` – usually `localhost` on shared hosting

Confirm each value in cPanel. Our guide to [finding your MySQL database details](https://jethost.com/kb/how-to-find-your-mysql-database-details-on-cpanel/) shows where to look, and [managing MySQL user privileges](https://jethost.com/kb/how-to-manage-mysql-user-privileges/) covers making sure the user is attached to the database.

## Check the database is running

If the details are right, confirm the database itself is healthy:

1. Open [phpMyAdmin](https://jethost.com/kb/phpmyadmin/) in cPanel and check the database and its tables are listed.
2. If pages load but the admin shows a database error, add `define('WP_ALLOW_REPAIR', true);` to `wp-config.php`, then visit `yourdomain.com/wp-admin/maint/repair.php` and run the repair. Remove the line afterwards.
3. You can also [repair and optimize the database](https://jethost.com/kb/how-to-repair-optimize-a-mysql-database/) from phpMyAdmin.

## Rule out a traffic or resource spike

If the error comes and goes, the database may be hitting a limit under load – too many connections, or a plugin running heavy queries. Check for a traffic spike, pause a suspect plugin, and watch whether the error returns. On a busy site this is often a sign you have outgrown your current plan.

## On JetHost hosting

If the details check out and the database still will not answer, the server side may need a look. Open a ticket and we’ll check the database service and your account’s resources. If you are regularly hitting limits, we can help you move to a plan that fits the traffic.

## JetHost Experts Tip

Back up wp-config.php before you edit it. One wrong character in the database lines will keep the site down, so a copy lets you undo in seconds.

## Frequently asked questions

**Why did this start without me changing anything?**A traffic spike, a plugin update, or the host restarting the database service can trigger it. If it clears on its own but keeps coming back, suspect load or resources.

**Will I lose my content?**No. The error is about reaching the database, not losing it. Your posts and pages are still stored; once the connection works, they appear again.

**The front end works but wp-admin shows the error. Why?**That points to corrupted tables. Run the built-in database repair, then repair and optimize from phpMyAdmin.

## New Hosting Plan with 80% OFF

Upgrade your website’s home without the heavy bill. Get new [hosting plan](https://jethost.com/web-hosting/ "Web hosting with free SSH access") with a huge 80% discount. Get free SSL, email accounts, and a control panel to manage your site. Enjoy fast performance, secure environment, and 24/7 support - all in one affordable package.

## Need more help?

Still stuck on “Error establishing a database connection” with us? Open a ticket through Client Area → Support Tickets and we’ll check the database and your credentials.
