Score:0

Postfix occasionally stops working until restart

gb flag

I have configured Postfix to send all emails to a smart host, and it can work for weeks without problems. But every now and then it stops working and shows messages such as these in the log (the first two lines are for the last successful sending, and the last two are the first message that fails to go out):

Nov 24 20:05:30 nextcloud postfix/smtp[443568]: 3882C1B5D8A: to=<xxxxxx>, relay=relay.grnet.gr[83.212.2.185]:587, delay=2.3, delays=1.3/0/0.02/1, dsn=2.0.0, status=sent (250 OK id=1oyGbJ-0001PM-H2)
Nov 24 20:05:30 nextcloud postfix/qmgr[193834]: 3882C1B5D8A: removed
Nov 24 20:44:43 nextcloud postfix/postfix-script[1563]: warning: symlink leaves directory: /etc/postfix/./makedefs.out
Nov 24 20:44:46 nextcloud postfix/postfix-script[1751]: warning: /var/spool/postfix/etc/resolv.conf and /etc/resolv.conf differ
Nov 24 20:44:46 nextcloud postfix/postfix-script[1772]: starting the Postfix mail system
Nov 24 20:44:46 nextcloud postfix/master[1774]: daemon started -- version 3.4.13, configuration /etc/postfix
Nov 24 21:05:19 nextcloud postfix/smtpd[4252]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
Nov 24 21:05:19 nextcloud postfix/smtpd[4252]: connect from localhost[127.0.0.1]
Nov 24 21:05:19 nextcloud postfix/smtpd[4252]: E76A51B5819: client=localhost[127.0.0.1]
Nov 24 21:05:20 nextcloud postfix/cleanup[4257]: E76A51B5819: message-id=<[email protected]>
Nov 24 21:05:20 nextcloud postfix/smtpd[4252]: disconnect from localhost[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Nov 24 21:05:20 nextcloud postfix/qmgr[1776]: E76A51B5819: from=<xxxxxx>, size=37076, nrcpt=1 (queue active)
Nov 24 21:05:21 nextcloud postfix/smtp[4258]: E76A51B5819: to=<xxxxxx>, relay=none, delay=0.36, delays=0.33/0.03/0/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=relay.grnet.gr type=MX: Host not found, try again)

Subsequently it remains in this status for ever (it was once stuck for about three weeks until I found out); all messages fail and remain in the queue. When I restart it, it works again, sends all the deferred messages, and works happily until the next time the problem occurs.

How can I configure it to be resilient and not require a restart?

I'm using Postfix 3.4.13 in Ubuntu 20.04. Here is /etc/postfix/main.cf:

myorigin = /etc/mailname
biff = no
compatibility_level = 3
relayhost = relay.grnet.gr:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
inet_interfaces = loopback-only
virtual_alias_maps = hash:/etc/postfix/virtual
masquerade_domains = grnet.gr
Nikita Kipriyanov avatar
za flag
Probably your DNS resolution breaks? Are there any correlations with other things that happen on the server? Also, how exactly did you configured a smart host, can we see your configuration?
gb flag
@NikitaKipriyanov I added the configuration to the question. It's possible that the DNS breaks. Even if it does, it always fixes itself. But Postfix remains broken until restarted. Shouldn't it come back up when whatever problem goes away?
Score:1
za flag

The way you specified relayhost makes it to do a MX lookup on the specified name and use that name to look up the address of the server where to connect to 587. This is why it says "MX: Host not found, try again".

If relay.grnet.gr is the literal name of the MX server (and not a domain name where MX records exist that specify MX servers), put it into square brackets to suppress this MX lookup and use A record:

relayhost = [relay.grnet.gr]:587

Look also man 5 postconf

gb flag
Thanks! So the strange thing isn't that it was sometimes failing—it's that sometimes it was working. Go figure...
Nikita Kipriyanov avatar
za flag
Yes, I was about to write the same :)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.