1

On a Rocky Linux version 8.5 machine (a bug-for-bug compatible Red Hat Enterprise Linux downstream), I have configured Postfix + Dovecot setup. After troubleshooting all configuration errors, I got to the point where both services would at least launch.

systemctl enable dovecot.service
systemctl enable postfix.service

After restarting the machine, I could see Dovecot launched properly when queried using systemctl status dovecot. Postfix, on the other hand, failed to start, reporting:

[root@mail ~]# 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 ...; 12min ago
  Process: 1419 ExecStart=/usr/sbin/postfix start (code=exited, status=1/FAILURE)
  Process: 1396 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
  Process: 1364 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)

systemd[1]: Starting Postfix Mail Transport Agent...
postfix/postfix-script[1506]: fatal: the Postfix mail system is already running
systemd[1]: postfix.service: Control process exited, code=exited status=1
systemd[1]: postfix.service: Failed with result 'exit-code'.
systemd[1]: Failed to start Postfix Mail Transport Agent.

A quick check using postfix status showed indeed it is not running. Surprisingly though, postfix start then started the service without any issues. Querying postfix status then reported Postfix is happily running with a new PID. Querying systemctl status postfix one more time after that showed the unchanged error report from before.

The error reported makes no sense, however. I can systemctl disable postfix, restart the machine, check Postfix is truly not running using both systemctl status postfix and postfix status, try to enable it using systemctl start postfix and get the same error.

Furthermore, if I leave Postfix service disabled in systemd, reboot the machine and only start it with postfix start, the service kicks in, but systemctl status postfix reports it as loaded, inactive...

[root@mail ~]# postfix start
postfix/postfix-script: starting the Postfix mail system
[root@mail ~]# postfix status
postfix/postfix-script: the Postfix mail system is running: PID: 2169
[root@mail ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
[root@mail ~]#

Why does Postfix on RHEL even come registered as a service when it categorically refuses to work as such? And what is then the proper way to ensure Postfix starts at boot?

Note: I tried chkconfig postfix on as I found it suggested by people online. That merely forwards the request to systemctl enable postfix.service which leads me back to the start.

... do I really have to hack it in using /etc/rc.local, when the contents of the file itself say it's there only for compatibility purposes, shouldn't be used anymore and I should consider working with systemd services?

UPDATE 1: I went with what seemed like a reasonable workaround for the time being - starting postfix using the postfix start command in /etc/rc.local. After reboot, Postfix still wasn't running. Checking the status of the rc-local service using systemctl status rc-local, the service failed to start, the reason in the logs being exactly the same as the reasons stated in the Postfix service logs after I enabled it through systemctl - "fatal: the Postfix mail system is already running". Postfix is simply failing to start at startup under all conditions.

Marty Cagas
  • 113
  • 7

1 Answers1

1

This sounds like a SysV and systemd conflict. Try to disable the service in systemd and reboot and see whether it runs. It probably will be running.

sudo systemctl disable posfix
sudo init 6

Note that I use init 6 because that is the rawest way to reboot. The reboot and shutdown functions do additional things which may cause side effects. The newest method is actually systemctl reboot, but I have not used it yet.

That should give you no errors and it is likely to be running.

If using SysV, then you should see links under /etc/rc?.d (where ? is a number from 1 to 6) that refer postfix.

Also, it could be that postfix detects that it's already running by checking the PID file instead of whether a process with that PID is indeed running. That would be my next attempt. I often do a clean stop before a start when a process failed to start so such cleanups have a chance to get reset:

systemctl stop postfix
systemctl start postfix
Alexis Wilke
  • 2,057
  • 1
  • 18
  • 33
  • Thank you for your reply! After disabling Postfix in _systemd_ and rebooting, it wasn't running neither when checking `systemctl status postfix`, nor the `postfix status` (which to my knowledge is their own wrapper for controlling the server). I will look into SysV and see if I can get it to launch on startup that way. – Marty Cagas Mar 05 '22 at 22:25
  • 1
    In the end, the issue was not in the SysV, but in me using `reboot` instead of the correct `init 6` or `systemctl reboot`. As explained in another answer [here](https://unix.stackexchange.com/a/64385/383614), they are technically different and, in this situation, the difference was enough to break Postfix. I couldn't have figured it out without your answer so it doesn't feel right to write my own and accept it, but for the sake of someone in the future struggling with the same problem, could you edit a mention of this into your answer? – Marty Cagas Mar 06 '22 at 19:27
  • 1
    @MartyCagas Done. – Alexis Wilke Mar 07 '22 at 17:01