Postfix with Amavis returns "name=localhost type=A: Host not found" in mail.log

ajmcello asked:

Full error:

Dec 23 19:44:31 example.com postfix/pickup[5589]: 39332276875: uid=0 from=<fredflinstone>
Dec 23 19:44:31 example.com postfix/cleanup[5605]: 39332276875: message-id=<20161223194431.39332276875@example.com>
Dec 23 19:44:31 example.com postfix/qmgr[5590]: 39332276875: from=<fredflinstone@example.com>, size=300, nrcpt=1 (queue active)
Dec 23 19:44:31 example.com postfix/smtp[5607]: 39332276875: to=<FredGSanford@example.com>, relay=none, delay=0.05, delays=0.03/0.01/0.01/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=localhost type=A: Host not found)
Dec 23 19:44:31 example.com postfix/cleanup[5605]: 453F3276876: message-id=<20161223194431.453F3276876@example.com>
Dec 23 19:44:31 example.com postfix/bounce[5608]: 39332276875: sender non-delivery notification: 453F3276876
Dec 23 19:44:31 example.com postfix/qmgr[5590]: 453F3276876: from=<>, size=2273, nrcpt=1 (queue active)
Dec 23 19:44:31 example.com postfix/qmgr[5590]: 39332276875: removed
Dec 23 19:44:31 example.com postfix/local[5609]: 453F3276876: to=<FredGSanford@example.com>, orig_to=<fredflinstone@example.com>, relay=local, delay=0.02, delays=0.01/0/0/0.01, dsn=2.0.0, status=sent (delivered to maildir)
Dec 23 19:44:31 example.com postfix/qmgr[5590]: 453F3276876: removed

Localhost is in /etc/hosts. Can ping it. Could it be nsswitch.conf, or host.conf? Mail delivers fine when I disable amavis from postfix. Here is my postfix configuration:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
compatibility_level = 2
content_filter = smtp-amavis:[localhost]:10024
home_mailbox = Maildir/
inet_interfaces = all
inet_protocols = ipv4
mailbox_size_limit = 0
mydestination = $myhostname, example.com, localhost
myhostname = example.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
policy-spf_time_limit = 3600s
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_recipient_restrictions = , check_policy_service unix:private/policy-spf, check_policy_service unix:private/policy-spf
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_auth_only = no
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = no
tls_random_source = dev:/dev/urandom

/etc/nsswitch.conf

hosts:          files resolv [!UNAVAIL=return] mdns4_minimal [NOTFOUND=return] dns myhostname

/etc/host.conf

order hosts,bind
multi on

/etc/hosts

127.0.0.1 localhost
10.0.7.4  localhost example.com localhost.example.com
::1 localhost ip6-localhost ip6-loopback

/etc/postfix/master.conf

smtp      inet  n       -       y       -       -       smtpd
pickup    unix  n       -       y       60      1       pickup
cleanup   unix  n       -       y       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
tlsmgr    unix  -       -       y       1000?   1       tlsmgr
rewrite   unix  -       -       y       -       -       trivial-rewrite
bounce    unix  -       -       y       -       0       bounce
defer     unix  -       -       y       -       0       bounce
trace     unix  -       -       y       -       0       bounce
verify    unix  -       -       y       -       1       verify
flush     unix  n       -       y       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       y       -       -       smtp
relay     unix  -       -       y       -       -       smtp
showq     unix  n       -       y       -       -       showq
error     unix  -       -       y       -       -       error
retry     unix  -       -       y       -       -       error
discard   unix  -       -       y       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       y       -       -       lmtp
anvil     unix  -       -       y       -       1       anvil
scache    unix  -       -       y       -       1       scache
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix  -       n       n       -       2       pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

policy-spf unix    -       n       n       -       0     spawn
      user=nobody argv=/usr/bin/policyd-spf

smtp-amavis unix    -       -       -       -       2     smtp
     -o smtp_data_done_timeout=1200
     -o smtp_send_xforward_command=yes
     -o smtp_tls_note_starttls_offer=no

127.0.0.1:10025 inet n    -       -       -       -     smtpd
     -o content_filter=
     -o smtpd_delay_reject=no
     -o smtpd_client_restrictions=permit_mynetworks,reject
     -o smtpd_helo_restrictions=
     -o smtpd_sender_restrictions=
     -o smtpd_recipient_restrictions=permit_mynetworks,reject
     -o smtpd_data_restrictions=reject_unauth_pipelining
     -o smtpd_end_of_data_restrictions=
     -o smtpd_restriction_classes=
     -o mynetworks=127.0.0.0/8
     -o smtpd_error_sleep_time=0
     -o smtpd_soft_error_limit=1001
     -o smtpd_hard_error_limit=1000
     -o smtpd_client_connection_count_limit=0
     -o smtpd_client_connection_rate_limit=0
     -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_milters
     -o local_header_rewrite_clients=
     -o smtpd_milters=
     -o local_recipient_maps=
     -o relay_recipient_maps=

NOTE Content filter. If I comment that out, mail delivers just fine. So the problem is with amavis? New installation on new server. Ubuntu 16.10

My answer:


You have an error in /etc/hosts.

You’ve defined 10.0.7.4 localhost, which is a great way to break localhost. This should not be present and should be removed immediately.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.