How can I fix the error: Host '127.0.0.1' is not allowed to connect to this MariaDB server?

Overview

This article provides resolution steps for the MariaDB connection error Host '127.0.0.1' is not allowed to connect to this MariaDB server. This issue typically prevents Amavis from processing mail and results in message delivery failures.

Error Log Example

The following entries may appear in the system mail log when this error occurs:

Apr  4 11:01:15 alma amavis[3540852]: (3540852-05) (!)connect_to_sql: unable to connect to DSN 'DBI:MariaDB:database=danami_warden;host=127.0.0.1': Host '127.0.0.1' is not allowed to connect to this MariaDB server
Apr  4 11:01:15 alma amavis[3540852]: (3540852-05) (!!)TROUBLE in check_mail: gen_mail_id FAILED: connect_to_sql: unable to connect to any dataset at /usr/share/perl5/vendor_perl/Amavis/Out/SQL/Connection.pm line 255.
Apr  4 11:01:15 alma postfix/cleanup[3534095]: 8AD7A1004203BC: milter-reject: END-OF-MESSAGE from localhost[127.0.0.1]: 4.5.0 Error in processing, id=3540852-05, gen_mail_id FAILED: connect_to_sql: unable to connect to any dataset at /usr/share/perl5/vendor_perl/Amavis/Out/SQL/Connection.pm line 255.; from=<root@alma.example.com> to=<root@alma.example.com>
Apr  4 11:01:15 alma psa-pc-remote[424364]: Message aborted.

Troubleshooting Steps

Follow the procedures below to identify and resolve the underlying cause. Perform each step sequentially until mail processing resumes normally.

Step 1: Verify MariaDB Configuration

The error may occur if the skip-name-resolve directive is enabled in the MariaDB configuration, which can restrict localhost connections depending on the server setup. To resolve this:

  • Open the main configuration file located at /etc/my.cnf.
  • Review all included configuration files within the /etc/my.cnf.d/ directory.
  • Locate the line containing skip-name-resolve = 1.
  • Comment out or remove this directive to disable it.
  • Save the changes and restart the MariaDB service:
systemctl restart mariadb

Step 2: Reset Warden Database Credentials

If adjusting the configuration does not resolve the issue, the error may be caused by missing or corrupted database credentials within the Warden configuration. Reset the credentials using the following commands:

  • Reset the Amavis database credentials:
// reset the Amavis database credentials
warden --task=contentfilter:contentfilter --default=yes --reload=yes
  • Reset the SpamAssassin learning database credentials:
// reset the SpamAssassin learning database credentials
warden --task=antispam:learning --default=yes --reload

Verification

After applying the appropriate fix, monitor the mail log to confirm that Amavis successfully connects to the MariaDB server and that message processing resumes without errors.

  • mariadb, skip-name-resolve
  • 0 Pengguna Menemukan Ini Berguna
Apakah jawaban ini membantu?

Artikel Terkait

How can I fix the error: Parse error at /etc/clamav/clamd.conf Unknown option ScanImage?

Overview The clamav-daemon.service may fail to start due to unrecognized configuration...

How can I fix the error: The domain limit of this license key has been reached?

Overview The Admin and Pro editions of Danami products enforce a maximum domain limit within the...

After upgrading from Centos 7 to AlmaLinux 8 Amavis is treating mail with low scores as spam. How can I fix this?

Overview Following an upgrade from CentOS 7 to AlmaLinux 8, Amavis may incorrectly classify...

How can I fix empty mail log information in Warden?

Overview Warden relies on the systemd-journal to retrieve and display mail log information. If...