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)
- Edit your MySQL configuration file (e.g.,
/etc/mysql/conf.d/enhance.cnf
). - Remove or comment out the following line if present:
skip-name-resolve
- 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.