How to fix the “Error Establishing a Database Connection” in WordPress

As a dynamic content management system, WordPress relies on a MySQL database that stores your content, website settings and more. If WordPress is unable to communicate with its database, you’ll see an error message stating: Error establishing a database connection.

Error message

If your WordPress website was previously working normally, clearly something has changed to break the link between WordPress and the database. Possible causes could be:

  • The database server is down.
  • A change has been made to the database credentials (hostname, username or password) in your wp-config.php file.

If this is the first time you’ve tried to use WordPress, the most likely cause is that your database credentials are incorrect or have changed. Use the following steps to troubleshoot the issue.

Check your WordPress configuration

When installing WordPress, you will have been asked to input a database hostname, database name, database username and password. These credentials are stored in your wp-config.php file. A great first step for troubleshooting database connection errors is to check that the database credentials in your wp-config.php file are correct.

You can use an FTP client to access the file on your HostPapa Server, or alternatively, use cPanel File Manager.

HostPapa Dashboard

Log in to your HostPapa Dashboard and select My cPanel.

My cPanel Menu

Now select File Manager.

cPanel

Navigate to your WordPress folder and look for your wp-config.php file. Right click on the file and select Edit.

cPanel File Manager

You’ll see your database credentials listed under MySQL settings. Check that the database hostname, database name, database username and password are correct. You can find your database credentials at My cPanel > MySQL Databases.

MySQL configuration

Make any necessary changes in your wp-config.php file and then click Save Changes to proceed. Try to access WordPress once again to see if your issue remains.

Check your database server

If your credentials are correct, or changing them has not resolved the issue, your next step should be to check to see if the MySQL Database Server is running. The easiest way to do this is by contacting HostPapa Support. Please open a support ticket from your HostPapa Dashboard. Follow this link to learn how.

Related Articles

Get online with our affordable web hosting

Get online with our affordable web hosting

Learn more now
HostPapa Mustache