How to fix postfix/smtp Network is unreachable error

When trying to send email to a gmail account through postfix you can see an error like this in the postfix logs /var/log/maillog :

Mar 10 14:16:22 mail.nucleiotechnologies.com postfix/smtp[35387]: connect to smtp.gmail.com[2404:6800:4008:c07::6c]:587: Network is unreachable

Solution for IPv4

 If you want to use IPv4 instead, then you should edit the Postfix configuration file:

sudo nano /etc/postfix/main.cf

And change inet_protocols = all to inet_protocols = ipv4 and restart or reload Postfix:

sudo service postfix restart

Solution for IPv6

A common cause is because of wrong IPv6 settings. Correct your IPv6 settings and try again. Example IPv6 configs are shown below,

vi /etc/network/interfaces

For example:

iface eth0 inet6 static
 address 2a00:d880:0:10::xxxx:xxxx
 netmask 64
 gateway 2a00:d880:0:10::1
 up ip -6 addr add 2a00:d880:0:10::xxxx:xxxx/64 dev eth0
 up ip -6 addr add 2a00:d880:0:10::xxxx:xxxx/64 dev eth0
 up ip -6 addr add 2a00:d880:0:10::xxxx:xxxx/64 dev eth0
 up ip -6 addr add 2a00:d880:0:10::xxxx:xxxx/64 dev eth0

Sample IPv6 configuration for CentOS:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

For example:

IPV6INIT=yes
 IPV6ADDR=2a00:d880:0:10::xxxx:xxxx
 IPV6_DEFAULTGW=2a00:d880:0:10::1
 IPV6ADDR_SECONDARIES="2a00:d880:0:10::xxxx:xxxx/64 2a00:d880:0:10::xxxx:xxxx/64 2a00:d880:0:10::xxxx:xxxx/64 2a00:d880:0:10::xxxx:xxxx/64"

Reference: https://www.e2enetworks.com/help/knowledge-base/howto-fix-postfixsmtp-network-is-unreachable-error/

Leave a Comment

Your email address will not be published. Required fields are marked *