Postfix: Cannot assign requested address

emailgmailpostfix

I have app that uses postfix. When i send an email from one user to another, works well, as you can see here

Sep 28 14:34:04 webcat-node-77f77644-vhq94 postfix/smtpd[546]: connect
from localhost[127.0.0.1] Sep 28 14:34:04 webcat-node-77f77644-vhq94
postfix/smtpd[546]: EA382280CA4: client=localhost[127.0.0.1] Sep 28
14:34:04 webcat-node-77f77644-vhq94 postfix/cleanup[551]: EA382280CA4:
message-id=<504605561.1538145244923.JavaMail.root@webcat-node-77f77644-vhq94> Sep 28 14:34:04 webcat-node-77f77644-vhq94 postfix/qmgr[146]:
EA382280CA4: from=, size=1232, nrcpt=1 (queue
active) Sep 28 14:34:04 webcat-node-77f77644-vhq94 postfix/smtpd[546]:
disconnect from localhost[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1
quit=1 commands=5 Sep 28 14:34:06 webcat-node-77f77644-vhq94
postfix/smtp[552]: EA382280CA4: to=,
relay=smtp.gmail.com[74.125.133.108]:587, delay=1.1,
delays=0.01/0.03/0.4/0.69, dsn=2.0.0, status=sent (250 2.0.0 OK
1538145246 h71-v6sm1532424wmg.4 – gsmtp) Sep 28 14:34:06
webcat-node-77f77644-vhq94 postfix/qmgr[146]: EA382280CA4: removed

The problem comes when someone uses the feedback feature in my app.

Sep 28 14:28:21 webcat-node-77f77644-vhq94 postfix/smtpd[531]: connect
from localhost[127.0.0.1] Sep 28 14:28:21 webcat-node-77f77644-vhq94
postfix/smtpd[531]: A0507280CA4: client=localhost[127.0.0.1] Sep 28
14:28:21 webcat-node-77f77644-vhq94 postfix/cleanup[535]: A0507280CA4:
message-id=<634841788.1538144901634.JavaMail.root@webcat-node-77f77644-vhq94> Sep 28 14:28:21 webcat-node-77f77644-vhq94 postfix/qmgr[146]:
A0507280CA4: from=, size=702, nrcpt=1 (queue active)
Sep 28 14:28:21 webcat-node-77f77644-vhq94 postfix/smtpd[531]:
disconnect from localhost[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1
quit=1 commands=5 Sep 28 14:28:21 webcat-node-77f77644-vhq94
postfix/smtp[536]: connect to
smtp.gmail.com[2a00:1450:400c:c06::6c]:587: Cannot assign requested
address Sep 28 14:28:22 webcat-node-77f77644-vhq94 postfix/smtp[536]:
A0507280CA4: to=,
relay=smtp.gmail.com[74.125.71.108]:587, delay=1.1,
delays=0.01/0.02/0.34/0.78, dsn=2.0.0, status=sent (250 2.0.0 OK
1538144902 u4-v6sm3253917wro.47 – gsmtp) Sep 28 14:28:22
webcat-node-77f77644-vhq94 postfix/qmgr[146]: A0507280CA4: removed

This is the content of my main.cf :

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

append_dot_mydomain = no

readme_directory = no
compatibility_level = 2

smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = myDomain
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = gdfg, $myhostname, localhost.localdomain, localhost
relayhost = [smtp.gmail.com]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_protocols = all
inet_interfaces = all
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_use_tls = yes
myorigin = /etc/mailname

Best Answer

The delivery attempt on the second log excerpt tries to use IPv6 and after failing, falls back to IPv4 and delivers the message successfully. You can either fix your IPv6 host configuration if you have IPv6 upstream connection, or disable it on your system if you don't have IPv6, or you can prevent postfix from using your broken IPv6 by setting inet_protocols = ipv4 in main.cf