Postfix does not start correctly on linode reboot, not always.

As title.

When I reboot my linode, sometimes postfix does not start automatically, sometimes it starts automatically.

When postfix does not start automatically, if I manually start it, it starts without problems.

Using the latest version of CentOS

this is my config files

cat /usr/lib/systemd/system/postfix.service

[Unit]
Description=Postfix Mail Transport Agent
After=syslog.target network-online.target
Wants=network-online.target
Conflicts=sendmail.service exim.service

[Service]
Type=forking
PIDFile=/var/spool/postfix/pid/master.pid
EnvironmentFile=-/etc/sysconfig/network
ExecStartPre=-/usr/libexec/postfix/aliasesdb
ExecStartPre=-/usr/libexec/postfix/chroot-update
ExecStart=/usr/sbin/postfix start
ExecReload=/usr/sbin/postfix reload
ExecStop=/usr/sbin/postfix stop

[Install]
WantedBy=multi-user.target

cat /etc/systemd/system/multi-user.target.wants/postfix.service

[Unit]
Description=Postfix Mail Transport Agent
After=syslog.target network-online.target
Wants=network-online.target
Conflicts=sendmail.service exim.service

[Service]
Type=forking
PIDFile=/var/spool/postfix/pid/master.pid
EnvironmentFile=-/etc/sysconfig/network
ExecStartPre=-/usr/libexec/postfix/aliasesdb
ExecStartPre=-/usr/libexec/postfix/chroot-update
ExecStart=/usr/sbin/postfix start
ExecReload=/usr/sbin/postfix reload
ExecStop=/usr/sbin/postfix stop

[Install]
WantedBy=multi-user.target

any help will be really appreciated.

12 Replies

When that happens (postfix hasn't started automatically) then just run systemctl status postfix it should give you a brief report about postfix and the last few lines from the log. If that doesn't contain the error, then grep for postfix in /var/log/maillog or /var/log/messages.

@IfThenElse:

When that happens (postfix hasn't started automatically) then just run systemctl status postfix it should give you a brief report about postfix and the last few lines from the log. If that doesn't contain the error, then grep for postfix in /var/log/maillog or /var/log/messages.

thanks for the reply

 systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2018-01-19 19:11:46 CET; 7min ago
  Process: 865 ExecStart=/usr/sbin/postfix start (code=exited, status=1/FAILURE)
  Process: 853 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
  Process: 832 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)

Jan 19 19:11:45 netstar.dpsoftware.org systemd[1]: Starting Postfix Mail Transport Agent...
Jan 19 19:11:45 netstar.dpsoftware.org postfix[865]: fatal: parameter inet_interfaces: no local interface found for MYIPV6
Jan 19 19:11:46 netstar.dpsoftware.org systemd[1]: postfix.service: control process exited, code=exited status=1
Jan 19 19:11:46 netstar.dpsoftware.org systemd[1]: Failed to start Postfix Mail Transport Agent.
Jan 19 19:11:46 netstar.dpsoftware.org systemd[1]: Unit postfix.service entered failed state.
Jan 19 19:11:46 netstar.dpsoftware.org systemd[1]: postfix.service failed.

mmm

how can I solve this problem?

thanks

Create the file /etc/sysctl.d/80-network.conf with the following contents:

net.ipv4.ip_nonlocal_bind = 1
net.ipv6.ip_nonlocal_bind = 1

then try another reboot, postfix should bind properly to its port.

@IfThenElse:

Create the file /etc/sysctl.d/80-network.conf with the following contents:

net.ipv4.ip_nonlocal_bind = 1
net.ipv6.ip_nonlocal_bind = 1

then try another reboot, postfix should bind properly to its port.

done it, same error.

Indeed, I just noticed that the error is about the interface and not the port number.

It seems like the ipv6 interface is not coming up online during boot, at least not fast enough.

Are you using NetworkManager? have you enabled the "Network Helper" feature in your Linode's server profile?

Do you explicitly set the IPv6 address in your postfix?

@IfThenElse:

Indeed, I just noticed that the error is about the interface and not the port number.

It seems like the ipv6 interface is not coming up online during boot, at least not fast enough.

Are you using NetworkManager? have you enabled the "Network Helper" feature in your Linode's server profile?

Do you explicitly set the IPv6 address in your postfix?

Thanks for the reply

Yes, network helper enabled.

How can I explicitly set the ipv6 in postfix?

Its possible something else in your setup is affecting the IPv6 interface and doesn't allow postfix to start properly.

Look for inetprotocols under this page: http://www.postfix.org/IPV6README.html

@IfThenElse:

Its possible something else in your setup is affecting the IPv6 interface and doesn't allow postfix to start properly.

Look for inetprotocols under this page: http://www.postfix.org/IPV6README.html

my main.cf says this.

#inet_interfaces = all
#inet_interfaces = $myhostname
inet_interfaces = $myhostname, localhost
#inet_interfaces = all

# Enable IPv4, and IPv6 if supported
#inet_protocols = ipv4
inet_protocols = all

thanks.

I think that is ok this way no?

I believe that the proper way to do this, is to bind to everything by default:

inet_interfaces = all
inet_protocols = all

If you start to specify interfaces like myhostname/localhost then fall into the trap that you are currently in, basically any delay to start an interface will kill postfix.

Unless you have a specific reason, you should leave those settings set to "all" and use the bind_address settings, if you require postfix to listen to a specific IP address.

@IfThenElse:

I believe that the proper way to do this, is to bind to everything by default:

inet_interfaces = all
inet_protocols = all

If you start to specify interfaces like myhostname/localhost then fall into the trap that you are currently in, basically any delay to start an interface will kill postfix.

Unless you have a specific reason, you should leave those settings set to "all" and use the bind_address settings, if you require postfix to listen to a specific IP address.

You rock my friend. I really appreciate your help.

It solved my problem.

inet_interfaces = all
inet_protocols = all

do you think that this can create some security flaw?

thanks

No problem, I'm glad it worked.

Well, that would depend on how postfix is setup and what you are trying to achieve. I really don't know anything about your setup so I can't give a solid answer. Look at the postfix configuration template that I am using, maybe you'll get some ideas.

@IfThenElse:

No problem, I'm glad it worked.

Well, that would depend on how postfix is setup and what you are trying to achieve. I really don't know anything about your setup so I can't give a solid answer. Look at the postfix configuration template that I am using, maybe you'll get some ideas.

ok, thanks!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct