Articles in this section

SpamAssassin does not work: Connection refused

Plesk for Linux kb: technical

Applicable to:

  • Plesk for Linux

Symptoms

  • The following errors can be found in /var/log/maillog:

    # cat /var/log/maillog | grep -i fail | grep -i spam | less
    spamc[32154]: connect to spamd on 127.0.0.1 failed, retrying (#3 of 3): Connection refused

    Or

    # cat /var/log/maillog | grep -i fail | grep -i spam | less
    spamc[32154]: connect to spamd on ::1 failed, retrying (#3 of 3): Connection refused

  • The 127.0.0.1 IP address is assigned to several network interfaces:

    # ifconfig |grep -C 1 127
    lo Link encap:Local Loopback
    inet addr:127.0.0.1 Mask:255.0.0.0
    inet6 addr: ::1/128 Scope:Host
    --
    venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
    inet addr:127.0.0.1 P-t-P:127.0.0.1 Bcast:0.0.0.0 Mask:255.255.255.255

  • SpamAssassin service is listening to public IP:

    # netstat -tulpn | grep spam
    tcp 0 0 203.0.113.2:783 0.0.0.0:* LISTEN 1018/.spamassassin

Cause

Unclear.

Could be that SpamAssassin listens on port 783 over 127.0.0.1 IP address on several network interfaces.

Resolution

Note: This article may require additional administrative knowledge to apply. If any help required, contact the server’s administrator or hosting support.

Re-assign SpamAssassin work process on server IP address, e.g 203.0.113.2:

  1. Connect to the server via SSH.

  2. For the spamd service add the following parameters in /etc/sysconfig/spamassassin using the command below:

    # echo -e '\nSPAMDOPTIONS="-i 203.0.113.2 -A 203.0.113.2 --nouser-config --username=popuser --daemonize --helper-home-dir=/var/qmail --virtual-config-dir=/var/qmail/mailnames/%d/%l/.spamassassin --create-prefs --max-children=1"' >> /etc/default/spamassassin

  3. For spamc service edit /etc/mail/spamassassin/spamc.conf and add the parameter -d 203.0.113.2 in it.
    So the file will look as follows:

    # cat /etc/mail/spamassassin/spamc.conf
    -d 203.0.113.2

Re-assign SpamAssassin work process on localhost:

  1. Connect to the server via SSH

  2. Add the following parameters in /etc/default/spamassassin:

    # grep OPTIONS /etc/default/spamassassin | grep -v "#"
    OPTIONS="-i 127.0.0.1 -A 127.0.0.1 --create-prefs --daemonize --helper-home-dir=/var/qmail --max-children=1 --nouser-config --username=popuser --virtual-config-dir=/var/qmail/mailnames/%d/%l/.spamassassin"

  3. Restart the service:

    # systemctl stop spamassassin.service
    # systemctl start spamassassin.service

Was this article helpful?

Comments

1 comment
Date Votes
  • In my case (Ubuntu 24.04, Plesk installed using CLI script) spamd service was not enabled and not running.

    So I just had to start and enable autostart of the service to resolve the issue:

    systemctl start spamd.service
    systemctl enable spamd.service

     

    0

Please sign in to leave a comment.