Answer :
A “Error establishing a database connection” message in WordPress means that your website cannot communicate with its MySQL database. This issue can be caused by incorrect credentials, corrupted database tables, server problems, or changes made during migration.
This guide explains the most common causes and how to fix them on GHFS Hosting.
1. Check Database Credentials in wp-config.php (Most Common Fix)
Incorrect database information prevents WordPress from connecting.
In your hosting account:
-
Open Plesk
-
Go to File Manager
-
Open your WordPress folder (usually
/httpdocs/) -
Edit wp-config.php
Verify the following lines:
Make sure:
-
DB_NAME matches the correct database
-
DB_USER matches the assigned MySQL user
-
DB_PASSWORD is correct
-
DB_HOST is usually localhost in GHFS Hosting
2. Check Your Database Credentials in Plesk
To confirm the correct values:
-
Go to Databases
-
Select your database
-
Open User Management
-
Confirm the database username and password
If needed, you can reset the password and update it in wp-config.php.
3. Check if the Database Server is Running
In rare cases, the MySQL server may be temporarily overloaded.
Signs:
-
phpMyAdmin also fails to load
-
Other sites on the same hosting have issues
Solution:
-
Wait a few minutes
-
Try again
-
If issue continues, contact GHFS Hosting support
4. Repair WordPress Database (If Tables Are Corrupted)
Sometimes tables become broken, especially on WooCommerce sites.
Enable WordPress Repair Mode:
-
Edit wp-config.php
-
Add this line:
-
Go to:
-
Click Repair Database
After completion, remove the repair line for security.
5. Fix a Corrupted .htaccess File
Bad rules in .htaccess may block database access.
Regenerate .htaccess:
-
Rename
.htaccessto.htaccess-old -
Log in to WordPress admin
-
Go to Settings → Permalinks
-
Click Save to generate a fresh
.htaccess
6. Fix Database Overload (High Traffic / Large Site)
If your site has:
-
Heavy traffic
-
Many plugins
-
WooCommerce store
-
Bots scanning your site
The database may become overloaded.
Solutions:
-
Enable caching (LiteSpeed Cache, WP Super Cache, WP Rocket)
-
Optimize your database
-
Limit Heartbeat API
-
Use Cloudflare to reduce load
-
Upgrade to a higher hosting plan or VPS
7. Restore Database from a Backup (If Corruption Is Too Severe)
If tables are severely damaged:
-
Go to Plesk → Websites & Domains
-
Click Backup Manager
-
Choose a backup containing the working database
-
Restore only the database section
This can quickly restore your site.
8. If WordPress Was Recently Migrated
Migration often causes database connection errors due to:
-
Wrong DB name
-
Wrong DB username
-
Wrong password
-
Wrong DB hostname
Double-check everything in wp-config.php.
If you imported the database manually, ensure the import succeeded without errors.
9. When to Contact GHFS Hosting Support
Contact support if:
-
Your credentials are correct but the error still appears
-
phpMyAdmin does not open
-
Database tables appear missing
-
Import or restore fails
-
You believe the database server is down
-
You need expert help repairing a corrupted database
Support can check logs and repair database issues for you.