Knowledge Base

WordPress Tutorial: Fixing "Error Establishing a Database Connection"

Are you using WordPress and got an error on your site saying "Error establishing a database connection"? This occurs when your WordPress site is experiencing issues connecting to your database. This may be caused by one of the following reasons:

This error must be fixed right away as it prevents your website from loading, thereby affecting website traffic, sales, etc.

Error Establishing a Database Connection

Incorrect Database Credentials

This is one of the most common reasons why you have the “Error establishing a database connection” error message on your website. To fix this error, you should check and ensure the accuracy of your database credentials.

You can find your database information in your Account Manager and in the root folder of your WordPress site, accessible via FTP.

WordPress Hosting Package

If you have WordPress hosting from us, then you can follow the instructions below to find your database credentials in your Account Manager.

  1. Log in to your Account Manager via https://www.networksolutions.com/my-account/login.
  2. On the left side of the page, click WordPress.

    Network Solutions' Account Manager, highlighting WordPress Tab
     
  3. If you have multiple WordPress packages, select the package you want to access, then click Manage.
  4. On the right side of your WordPress Control Panel, under the Configurations section, click Database Manager.

    New WordPress Control Panel highlighting "Database Manager"
     
  5. Take note of the Database Name, Hostname, and Username listed in the MySQL Database table.

    New WordPress Control Panel MySQL Database page

 

Hosting Package that Uses WordPress

If you have WordPress installed in your hosting package, then you can follow the instructions below to locate your database credentials in your Account Manager.

  1. Log in to your Account Manager via https://www.networksolutions.com/my-account/login.
  2. On the left side of the page, click Hosting.

    Account Manager, Hosting Tab
     
  3. If you have multiple hosting packages, select the package where you installed your WordPress, then click Manage.
  4. Navigate to the Configurations section, then click Database Manager.

    DB Manager
     
  5. Take note of the Database Name, Server Name, and Username listed in the MySQL Database table.

    DB Credentials

To find your database credentials via FTP, you need to:

  1. Connect via FTP and browse the WordPress site's root folder.
  2. Locate the wp-config.php file.

    wp-config.php file
     
  3. Find the database name, database host, username, and password.

    Database Information
     
  4. Cross-reference the database information in the Account Manager with the information in the wp-config.php file.
Important: If the information does not match, the website files cannot connect to the database properly, thus having an “Error establishing a database connection” on your website.

Due to incorrect database credentials, your website fails to communicate with the database. You need to change the database connection string to resolve the issue and ensure data retrieval. Follow the steps below to fix the said error.

  1. Download the wp-config.php file using FTP.
  2. Fix the incorrect information.
    Note: You can use a program such as Notepad to edit the file.
  3. Re-upload and overwrite the file with the corrected information.
  4. Check your website to see if the error has been fixed.

 

Corrupted Database

A corrupted database contains data that has been altered to the point that it is no longer usable. This can be caused by faulty WordPress plugins or themes, or by a hacking incident. If you have cross-checked that the database credentials in the Account Manager match those in the wp-config.php file, then a corrupted database may be the cause of the website error. The recommended action is to restore your website using a backup version of the database. Please check WordPress Tutorial: How to Back Up and Restore a WordPress Website for steps on how to restore a backup version of your website and database.

 

Deleted Database

Your WordPress site will be unable to retrieve data if the database is deleted from your hosting account. If you have accidentally deleted your database, you can contact us to see if we can restore it.

 

Review

This is an article about how to fix “Error Establishing a Database Connection” in Wordpress. It covers three possible causes of the error: incorrect database credentials, a corrupted database, and a deleted database. The article also provides instructions on how to fix the error in each scenario. Some important tips to follow are: back up your website before making any changes and verify the information in your Account Manager against the data in the wp-config.php file.

You can learn more about WordPress hosting with Network Solutions by visiting our storefront or finding additional troubleshooting tips here.