WordPress problem fix
This usually means wrong credentials, a crashed database server, or a corrupted database. All three are recoverable, usually with zero data loss.
When WordPress shows 'error establishing a database connection', the site is up but cannot talk to its database. The cause is one of four things: wrong database credentials in wp-config.php, the database server is down or restarting, the database is corrupted, or the host has hit a connection limit. Your content is almost always still there. The fix is to confirm credentials, repair the database, and restart the service. Usually under an hour.
If any of these match, you are on the right page.
Every page shows the database connection error
It started right after a host migration or update
wp-admin is also unreachable
The error appears at busy traffic times then clears
If a host changed the password or you migrated, DB_USER, DB_PASSWORD, DB_HOST, or DB_NAME may be stale. This is the first check.
Shared hosts sometimes restart MySQL or MariaDB. If the service is down, no credentials will work until it is back.
A crash or bad import can corrupt a table. WordPress can self-repair with WP_ALLOW_REPAIR in wp-config.php.
Cheap shared hosts limit concurrent database connections. A traffic spike or a slow plugin query exhausts the pool and triggers the error.
The real method, in the order it works.
Open wp-config.php and confirm DB_HOST, DB_USER, DB_PASSWORD, and DB_NAME match what the host shows.
Try to log into phpMyAdmin or the host control panel with the same credentials to confirm.
Add define('WP_ALLOW_REPAIR', true) to wp-config.php and visit /wp-admin/maint/repair.php to repair tables.
Restart the database service or ask the host to restart it.
If a connection limit is the cause, fix the slow query or upgrade the host.
Real fix, from our work
A SaaS founder messaged us during a launch saying the marketing site was throwing database errors. Credentials were correct. Host showed MySQL using 100 percent of allowed connections. We found a poll plugin firing an unindexed query on every page view. Added the index, throttled the plugin, restarted MySQL. Site stayed up through the launch.
Written by Ali Yasin Jatoi
Founder of WebCare Studios. Ali has worked with WordPress for more than 10 years, including managing a fleet of 150+ sites with WP-CLI automation for updates, security cleanup, and malware removal. He has hands on experience across major hosts including Cloudways, A2 Hosting, Hostinger, and Bluehost.
Site down, hacked, or broken checkout gets a senior engineer within 4 hours. No ticket queues, no bots.
Flat quote up front. If we cannot get you back online, you do not pay. Risk sits with us, not you.
We work on a snapshot first and never touch your live database until the fix is verified safe.
We run a fleet of WordPress sites every day. The errors you are seeing are ones we have closed hundreds of times.
Almost never. The error means WordPress cannot reach the database, not that the database is destroyed. Once the connection is restored, all content returns.
Intermittent errors usually mean connection pool exhaustion or a flaky database server. The fix is to find what is opening too many connections, often a runaway plugin query or a backup job.
Sometimes. Wrong credentials are simple. Corruption and connection limits usually need someone who can read the slow query log and edit server config.
Wrong credentials take five minutes. Repair or restart takes thirty. Slow query or host capacity issues take a couple of hours to fix permanently.
Two fields. Email and your URL. A senior WordPress engineer reads it within minutes and replies on email and WhatsApp with what is wrong and what we will do next.