How to fix the error in database connection for WordPress
Before you make any database changes, make sure you have sufficient backups.
Why do you get this error?
You are getting this error because WordPress is unable to establish a database connection. Now the reason why WordPress is unable to establish a database connection can vary. It could be that due to the following reasons.
- Your database login credentials are wrong or have been changed
- Your database has been corrupted
- You do not have a database uploaded on your account
Checking the WP-Config file
Before proceeding, make sure that you have uploaded your database via Cpanel or phpMyAdmin.
WP-Config.php is where you specify the details for WordPress to connect your database. If you changed your root password, or the database user password, then you will need to change this file as well. First thing you should always check is if everything in your wp-config.php file is the same.
- define('DB_NAME', 'database-name');
- define('DB_USER', 'database-username');
- define('DB_PASSWORD', 'database-password');
- define('DB_HOST', 'localhost');
You can confirm the the details above by navigating to .
The following image show an example of how you can verify the database name and the database user.
Remember your 'DB_Host' value might not always be localhost. Depending on the server where your site is currently hosted.
In GWHS Staging server:
In GWHS Production 01 server:
In GWHS Production 02 server:
If everything in this file is correct (make sure you check for typos) but you still encounter the error, try re-uploading your database.
If the error on your database connection still persists, you may contact the ICT Office through the following details:
Or create a ticket onand our technical staff will provide you assistance.