Troubleshooting Database Connection Errors During cPFence Database Scans

cPFence uses Wordfence CLI as part of its database scanning process. If you encounter database connection errors during a scan, this guide will help you resolve them.

Common Error Message

You may see an error like this:

Error: (<wordfence.wordpress.database.WordpressDatabase object at ...>, 'Failed to connect to database: exampleuser@localhost:3306/exampledb')
Scan failed for: /var/www/example-site/public_html

This usually occurs when skip-name-resolve is enabled in your MySQL or MariaDB configuration. It causes issues because the database user may connect via localhost but not 127.0.0.1, and Wordfence CLI sometimes uses 127.0.0.1 for scanning.

Tip: On Enhance, you can’t use 127.0.0.1 because it points to the loopback address inside the website container, not the host operating system’s IP.

How to Fix

Easiest Solution: Change Database Settings (Server-Wide)

  1. Edit your MySQL configuration file (e.g., /etc/mysql/conf.d/enhance.cnf).
  2. Remove or comment out the following line if present:
skip-name-resolve
  1. Save the file and restart the database service:
sudo systemctl restart mysql

This allows database users to connect using both localhost and 127.0.0.1.

 


Need Further Assistance?

If you encounter any issues or need additional help, feel free to reach out to our support team via your client portal.

 

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

Is cPFence Compatible with Cloudflare, BunnyCDN and Quic.Cloud?

Yes, cPFence is fully compatible with Cloudflare, Quic.Cloud, and BunnyCDN. In fact, we recommend...

Why Do I See "could not change directory to /root: Permission denied" Warnings?

You may occasionally encounter the following warning message while using cPFence: could not...

How to Uninstall cPFence ?

If you need to remove cPFence from your system, follow the steps below to uninstall the software...

Configuring Hostname on Ubuntu for cPFence Emails and Features

Setting a proper hostname on your server is important for several reasons, including being able...

How to Set Up Slack Notifications in cPFence?

If you'd like to receive cPFence alerts on your desktop or mobile via Slack, follow the steps...