If WordPress shows "Error establishing a database connection" — no homepage, no admin — the WordPress code can't reach its database. Usually a configuration issue, sometimes a server issue.
Check wp-config.php
Open wp-config.php via FTP or the file manager. Look for:
define('DB_NAME', 'youraccount_wordpress');
define('DB_USER', 'youraccount_wpuser');
define('DB_PASSWORD', 'somepassword');
define('DB_HOST', 'localhost');
Check each:
DB_NAME— must exist as a database in cPanel → MySQL Databases. Names usually have ayouraccount_prefix.DB_USER— the user WordPress connects as. Same prefix convention.DB_PASSWORD— what you set when creating the user. If you've forgotten it, change the password in cPanel and updatewp-config.php.DB_HOST—localhostfor our hosting. Some hosts use a specific server name; ours doesn't.
If any value is wrong, fix it and reload the site.
Common causes
Password recently changed
If you changed the database user's password in cPanel but didn't update wp-config.php, this is the culprit. Update wp-config.php with the new password.
Database doesn't exist
If the database wp-config.php references doesn't exist (deleted, renamed, was never created):
- Open phpMyAdmin from your hosting.
- Look for the database.
- If missing, create it (via cPanel → MySQL Databases).
- If it exists under a different name, update
wp-config.phpto match.
User doesn't have access to the database
The database exists, the user exists, but the user doesn't have privileges:
- cPanel → MySQL Databases → scroll to "Add User to Database."
- Pick the user and the database.
- Grant All Privileges.
- Save.
WordPress can now connect.
Database server is down
Rare. If our database server is having issues, you'd see this error site-wide and we'd have a status page entry. Check status.flashcloud.com.
If the status page shows we're up but you're getting connection errors, open a ticket — it could be a database-specific issue we need to fix.
Database corruption
Even rarer. WordPress's "Database Repair" mode can fix:
- Add to
wp-config.php:define('WP_ALLOW_REPAIR', true); - Visit
https://yourdomain.com/wp-admin/maint/repair.php. - Click Repair Database or Repair and Optimize Database.
- After it finishes, remove the line from
wp-config.php(don't leave it on — anyone could trigger repair otherwise).
wp-config.php is corrupted
If you recently edited wp-config.php and it has a syntax error, WordPress can't parse it. Symptoms vary — sometimes white screen, sometimes the database error.
To check:
- Verify there are no missing semicolons, unclosed quotes, or stray characters.
- Compare against
wp-config-sample.php(in the WordPress folder) for reference. - If unsure, replace with a clean copy of
wp-config.phpfrom a backup.
Diagnosing further
If the basics check out and the error persists:
Test the database connection manually
Create a file called test-db.php in your WordPress folder:
Replace credentials with your actual ones. Visit https://yourdomain.com/test-db.php. If it says "Connected successfully," WordPress's wp-config.php has wrong credentials. If it shows an error, the credentials themselves are wrong.
Delete this file when done — leaving it accessible exposes your database credentials.
Check error logs
cPanel → Error Log shows recent server errors. Often there's a specific MySQL error message that explains the issue.
Or check wp-content/debug.log if you've turned on WP_DEBUG.
After fixing
Once the connection is restored:
- Verify all pages load — sometimes a partial fix leaves admin working but frontend broken.
- Check error logs for repeated issues.
- Make a backup — now is a good time, given the recent scare.
Power-user note
For sites with extreme database load (very large or busy), consider:
- Database optimization plugins (WP-Optimize) to clean up bloat.
- Object cache (Redis on Flashcloud is automatic) reduces database queries.
- Split databases — for huge sites, having WordPress in one database and other apps in others can help isolate load.
For most sites, the standard MariaDB + Redis setup on our hosting handles everything fine.