Loading...

Knowledge Base
Save up to  70% off.  Start your website today!

How to Fix “Error Establishing a Database Connection” in WordPress

Overview

As you maintain your WordPress site, you may encounter an "Error establishing a database connection" error message. This error suggests that your WordPress site is experiencing difficulties connecting to your database. This may be caused by one of the following:

  • Incorrect Database Credentials
  • Corrupted Database
  • Deleted Database

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

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 locate your database information in your Account Manager and in the WordPress site’s root folder, which can be accessed via FTP.

In this section, we will discuss:

How to Find My Database Credentials in My Account Manager

WordPress Hosting Package

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

  1. Log in to your Account Manager.
  2. On the left side of the page, click WordPress.
    WordPress Package
  3. If you have multiple WordPress packages, select the package you want to access, then click Manage.
  4. Under Configurations, click Database Manager.
    Database Manager
  5. Take note of the database name, database host, and username listed in the MySQL Database table.
    Database Credentials

 

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.
  2. On the left side of the page, click Hosting.
    Hosting Package
  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, database host, and username listed in the MySQL Database table.
    DB Credentials

 

How to Find My Database Credentials Via FTP

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.phpfile.
    Note: 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.

 

How to Fix the Database Connection Error

Due to incorrect database credentials, your website fails to communicate with your database. You must edit the database connection string so that it can retrieve data from the database. Follow the steps below to fix the database connection 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 is fixed.

A corrupted database has had its content altered to the point where it is no longer usable. Faulty WordPress plugins and themes may cause this, or you could have been hacked. If you have cross-checked the database credentials in the Account Manager with the credentials in the wp-config.php file and find that the information is consistent in both locations, then you can consider a corrupted database as the reason for the "Error establishing a database connection" on your website. The recommended course of action is to restore your website from a backup version of the database. Below are the steps for restoring your website files and database.

Select the option below:

WordPress Hosting Package

If you have WordPress hosting from us, then you can follow the instructions below.

  1. Log in to your Account Manager.
  2. On the left side of the page, click WordPress.
    WordPress
  3. If you have multiple WordPress packages, select the package you want to fix, then click the Manage button.
  4. On the Security section of the WordPress Control Panel, click Backups.
    WordPress Backups
  5. Select a backup version you want to restore, then click the Restore button.
    Restore Website

 

Hosting Package that Uses WordPress

If you have WordPress installed in your hosting package, then you can follow the instructions below.

  1. Log in to your Account Manager.
  2. On the left side of the page, select Hosting.
    Hosting
  3. If you have multiple Hosting packages, select the package where your WordPress is installed, then click the Manage button.
  4. In the Hosting Control Panel, navigate to the Configurations section, then click Website Backups.
    Website Backups
  5. Select the daily snapshot you wanted to restore, then click Restore to Snapshot.
    Restore Site

Your WordPress website will have nothing to connect to if the database is deleted from your hosting account. If you accidentally deleted your database, you can contact us to see if we can restore it.

 

Additional troubleshooting tips can be found here.

Did you find this article helpful?

 
* Your feedback is too short

Loading...