Knowledge Base

CodeGuard failed to connect to my database - what should I do?

Overview

By the end of this article, you will know why CodeGuard could not reach your database and which action restores your automatic backups. The article first explains how CodeGuard connects to a HostGator database, including the mysqldump command it runs remotely and the IP whitelist that allows it. It then lists the five known causes in a single reference table. Each cause has its own section below: database server maintenance, a deleted database user, a changed database user password, a deleted database, and missing IP whitelist entries. Two of those fixes rely on a CodeGuard Resource Sync, a HostGator action that recreates the database users and passwords CodeGuard needs, and one relies on the CodeGuard blacklist file, which tells CodeGuard to stop backing up a website or database. A verification section and frequently asked questions close the article.

How CodeGuard connects to your database

CodeGuard backs up a HostGator database by connecting to the HostGator server directly. The two services share credentials so that CodeGuard can sign in to the database on your behalf. For MySQL databases, CodeGuard runs mysqldump commands remotely from its own servers, which is only possible once HostGator has whitelisted the CodeGuard server IP addresses. If the credentials, the database, or the IP whitelist changes, the connection fails and the backup does not run.


Figure 1: CodeGuard database connection failure notification showing the “Failed to connect to the Database” error message and instructions to contact HostGator support to perform a CodeGuard Resource Sync.

Causes at a glance

CauseWhat happenedFix
Database server maintenanceThe HostGator database server was unavailable during routine maintenance.Confirm the maintenance window with HostGator support.
Database user deletedThe database user in the HostGator cPanel account was removed.Request a CodeGuard Resource Sync from HostGator support.
Database user password changedThe password for the database user was changed, so the stored credentials no longer work.Request a CodeGuard Resource Sync from HostGator support.
Database deletedThe database was removed from the HostGator server, so there is nothing to back up.Ask HostGator support to update the CodeGuard blacklist file, then request a Resource Sync.
CodeGuard IP addresses not whitelistedThe CodeGuard server IP addresses are missing from Remote MySQL access in cPanel.Add the CodeGuard IP addresses to Remote MySQL access in cPanel.

Cause 1 - Database server maintenance

Routine maintenance on the HostGator database server can make the server unreachable while the maintenance runs, which causes the CodeGuard connection to fail. Contact HostGator support and ask whether a maintenance window covered the time of the failed backup. If maintenance was the cause, no further action is needed. CodeGuard connects again on the next scheduled backup once the server is available.

Cause 2 - Database user deleted

If the database user in your HostGator cPanel account was deleted, CodeGuard no longer has an account to sign in with. Contact HostGator support and ask them to perform a CodeGuard Resource Sync. A CodeGuard Resource Sync is a HostGator action that recreates the database users and passwords CodeGuard needs and sends the current credentials to the CodeGuard service.

Cause 3 - Database user password changed

If the password for the database user was changed, the credentials stored by CodeGuard no longer match the server and the connection is refused. Contact HostGator support and ask them to perform a CodeGuard Resource Sync. The sync recreates the database users and passwords and passes the current credentials to CodeGuard, so you do not need to enter the new password anywhere yourself.

Cause 4 - Database deleted from the HostGator server

If the database was deleted from the HostGator server, CodeGuard keeps trying to back up a database that no longer exists. The fix is to tell CodeGuard to stop backing it up. Contact HostGator support and ask them to add the deleted database to the CodeGuard blacklist file, stored on the server at blacklist. The blacklist file tells CodeGuard which websites and databases to exclude from backups. After the file is updated, ask HostGator support to perform a CodeGuard Resource Sync so the CodeGuard service picks up the change.

Cause 5 - CodeGuard IP addresses not whitelisted

CodeGuard runs mysqldump remotely, so the HostGator server only accepts the connection if the CodeGuard server IP addresses are on the approved list. Add these IP addresses to Remote MySQL access in cPanel:

  • 54.236.233.46
  • 54.236.233.28
  • 54.174.91.34
  • 54.174.153.212
  • 54.174.115.171

If the database was created on or before January 1, 2014, also add these two IP addresses:

  • 184.72.217.230
  • 184.72.217.227

How to confirm the connection is working

Run a manual backup from your CodeGuard dashboard after the fix is applied, or wait for the next scheduled backup. A backup that completes without a connection error confirms that CodeGuard can reach the database again. If the error repeats, check the remaining causes in the table above and contact HostGator support with the date and time of the failed backup.

Frequently asked questions

What is a CodeGuard Resource Sync?

A CodeGuard Resource Sync is an action performed by HostGator support that recreates the database users and passwords CodeGuard uses, and sends the current credentials to the CodeGuard service. It resolves failures caused by a deleted database user or a changed database user password.

Who do I contact to fix a CodeGuard database connection error?

Contact HostGator support. The database server, the database user accounts, the blacklist file, and the Remote MySQL whitelist are all managed on the HostGator side.

What is the CodeGuard blacklist file?

The CodeGuard blacklist file is stored on the HostGator server at blacklist and lists the websites and databases CodeGuard should not back up. It is used when a database has been deleted and should no longer be included in backups.

Why does CodeGuard need my IP addresses whitelisted?

CodeGuard runs mysqldump commands remotely from its own servers rather than from your hosting account. The HostGator server rejects those remote connections unless the CodeGuard server IP addresses are added to Remote MySQL access in cPanel.

Similar questions

  • CodeGuard cannot connect to my database, how do I fix it?
  • Why did my CodeGuard database backup fail?
  • What IP addresses do I whitelist for CodeGuard in cPanel?
  • How do I request a CodeGuard Resource Sync from HostGator?
  • CodeGuard keeps trying to back up a database I deleted.

Need assistance?

Contact our team for help with your purchase or issuing your certificate.

Live chat

Call us today