How to Fix “Error Establishing a Database Connection” in WordPress
“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 nameDB_USER– the database userDB_PASSWORD– that user’s passwordDB_HOST– usuallylocalhoston shared hosting
Confirm each value in cPanel. Our guide to finding your MySQL database details shows where to look, and managing 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:
- Open phpMyAdmin in cPanel and check the database and its tables are listed.
- If pages load but the admin shows a database error, add
define('WP_ALLOW_REPAIR', true);towp-config.php, then visityourdomain.com/wp-admin/maint/repair.phpand run the repair. Remove the line afterwards. - You can also repair and optimize the 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
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.
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.
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 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.


