The message “Error Establishing a Database Connection” usually means your website cannot connect to its database.
This error is common on WordPress websites, but it can also affect other database-driven websites and applications.
The website files may still exist, but the website cannot load properly because it cannot read the database.
What Does This Error Mean?
A database connection error means the website tried to connect to the database but failed.
This may happen because:
- The database name is incorrect.
- The database username is incorrect.
- The database password is incorrect.
- The database server is unavailable.
- The database was deleted.
- The database user was removed.
- The website configuration file is incorrect.
- The database is damaged.
- The hosting account has reached a limit.
- A recent restore or migration used old details.
Why Is the Database Important?
Many websites store important information in the database.
For WordPress, the database stores:
- Pages
- Posts
- Users
- Settings
- Menus
- Plugin settings
- Theme settings
- Comments
- WooCommerce products
- WooCommerce orders
If the website cannot connect to the database, this information cannot be loaded.
Step 1 – Check Whether the Website Was Recently Changed
Think about whether anything changed before the error appeared.
For example:
- A website was moved.
- A backup was restored.
- A database password was changed.
- wp-config.php was edited.
- A database was deleted.
- A database user was removed.
- A developer made changes.
- WordPress was updated.
- A plugin caused a problem.
Recent changes often explain database connection errors.
Step 2 – Log Into DirectAdmin
Open your browser and visit: https://cp.yourdomain.co.za (Replace yourdomain.co.za with your own domain name.)
Enter your DirectAdmin username and password.
Click: Log In
Step 3 – Check That the Database Exists
Once you are logged into DirectAdmin, open the database area.
Click: Account Manager
Then click:Databases
Check whether the database still exists.
Locate: Database name, example: username_wp123
If the database is missing, it may need to be restored from backup.
Step 4 – Check Which Database the Website Uses
If your website uses WordPress, check the wp-config.php file.
Click: System Info & Files
Then click: File Manager
Open the WordPress folder.
For most websites, click: domains
Then click: yourdomain.co.za
Then click: public_html
Locate: wp-config.php
Open the file carefully and check the database settings.
Look for:
DB_NAME
DB_USER
DB_PASSWORD
DB_HOST
Do not change anything unless you know the correct details.
Step 5 – Compare the Database Name
Compare the DB_NAME value in wp-config.php with the databases listed in DirectAdmin.
If DB_NAME does not match an existing database, the website may be pointing to the wrong database or the database may be missing.
Step 6 – Check the Database User
Compare the DB_USER value in wp-config.php with the database users shown in DirectAdmin.
If the database user is missing or incorrect, the website may not be able to connect.
Step 7 – Check the Database Password
If the database password was recently changed, the website configuration file must also be updated with the new password.
For WordPress, this means updating the DB_PASSWORD value in wp-config.php.
Only change the password value if you are sure you have the correct database password.
Step 8 – Check phpMyAdmin
You can also check whether the database opens in phpMyAdmin.
Click: Account Manager
Then click:Databases
Then click: phpMyAdmin
Select the database from the left-hand side.
If phpMyAdmin cannot access the database, or the database does not appear, there may be a database or permission problem.
Step 9 – Restore the Database if Needed
If the database was deleted or damaged, you may need to restore it from JetBackup.
Use a backup date from before the issue started.
If the website files were also restored, try to restore the database from the same backup date.
This helps keep the website files and database in sync.
Common Causes and Fixes
Database missing
Restore the database from JetBackup or contact HostworX Support.
Wrong database name
Update the website configuration file with the correct database name.
Wrong database username
Use the correct database user assigned to the database.
Wrong database password
Update the website configuration file with the correct database password.
Database user missing
Create or restore the correct database user, or contact HostworX Support.
Recent migration
Check that the database name, user, password, and host were updated correctly.
Important Notes
Please keep the following in mind:
- This error usually means the website cannot connect to the database.
- WordPress database details are stored in wp-config.php.
- Changing wp-config.php incorrectly can break the website further.
- Restoring a database may overwrite current data.
- If unsure, contact HostworX Support before making changes.
- HostworX backups are kept for 14 days.
When Should I Contact HostworX Support?
Contact HostworX Support if:
- The database is missing.
- You do not know the correct database password.
- The database user is missing.
- phpMyAdmin shows an error.
- The website was recently restored or migrated.
- The error appeared after a hosting or database change.
- You are unsure which backup date to restore.
- You are not comfortable editing wp-config.php.
Please include the website address and any recent changes that were made.
Conclusion
“Error Establishing a Database Connection” means the website cannot connect to its database.
The most common causes are incorrect database details, a missing database, a changed password, or a restore or migration issue.
Check the database name, database user, password, and wp-config.php settings carefully before making changes.


