Every domain has a small set of instructions stored in DNS that tell the internet where to find its website, where to deliver its email and who is allowed to send mail or issue certificates for it. Those instructions are called DNS records. You rarely need more than six types, and once you know what […]
WordPress “Error Establishing a Database Connection”: 6 Causes and How to Fix It
Your WordPress site suddenly shows a plain white page that says “Error establishing a database connection”. Visitors can’t see anything, and the admin is locked too. The message means WordPress could not talk to its MySQL/MariaDB database. Here are the six most common causes, in the order worth checking. Take a backup before changing anything.
1. Wrong database details in wp-config.php
Open wp-config.php in cPanel File Manager and compare DB_NAME, DB_USER, DB_PASSWORD and DB_HOST with the database and user listed under MySQL Databases in cPanel. This is the usual cause right after a migration or a password change. If your browser shows a security warning instead, read our SSL error guide.
2. The database user lost its privileges
In cPanel > MySQL Databases, make sure the user is still added to the database with All Privileges. Re-add it if not.
3. The MySQL server is down or overloaded
If other sites on the same account fail too, the database service may have stopped or hit its limits. On shared plans, contact your host. On a VPS you can restart the service yourself and check memory use.
4. Corrupted tables
Add define('WP_ALLOW_REPAIR', true); to wp-config.php, open /wp-admin/maint/repair.php, run the repair, then remove the line again.
5. Resource limits on your hosting plan
Traffic spikes, heavy plugins or bots can exhaust database connections. If it keeps happening, it may be time to move from shared hosting to a VPS, or review your shared hosting plan. Very heavy sites may eventually need a dedicated server.
6. Wrong DB_HOST after moving servers
Most cPanel servers use localhost, but some setups need a specific hostname. After a move, work through our broken-after-switching-hosts checklist and the manual WordPress move guide.
Related: if the site shows a 500 error rather than a database message, follow our 500 Internal Server Error fix guide.
FAQ
Will I lose my content?
Usually not. The posts are still in the database; WordPress just can’t reach it.
Why does the front end fail but wp-admin shows a different error?
That points to corrupted tables. Use the repair step above.
Who can help?
Salasar Hosting support: +91 99620 05753.
