Symptoms
-
Fail2ban does not start with the following error in Plesk:
PLESK_ERROR: Unable to manage service by f2bmng: (‘start’, ‘fail2ban’). Error: Job for fail2ban.service failed because a timeout was exceeded. See “systemctl status fail2ban.service” and “journalctl -xe” for details. ERROR:f2bmng:Failed to start fail2ban service
-
Service status shows the following error:
# systemctl status fail2ban.service
● fail2ban.service – Fail2ban Service
…
CGroup: /system.slice/fail2ban.service
└─18598 /usr/bin/python /usr/bin/fail2ban-server -s /var/run/fail2ban/fail2ban.sock -p /var/run/fail2ban/fail2ban.pid -x -b
…
plesk systemd[1]: PID file /var/run/fail2ban.pid not readable (yet?) after start. -
PID file
does not exist:
/var/run/fail2ban.pid
# ls -lha /var/run/fail2ban.pid
ls: cannot access /var/run/fail2ban.pid: No such file or directory -
Another PID file is configured in
:
/etc/fail2ban/fail2ban.conf# grep pidfile /etc/fail2ban/fail2ban.conf
# Option: pidfile
pidfile = /var/run/fail2ban/fail2ban.pid
Cause
Misconfiguration of the Fail2ban service.
Resolution
- Connect to the server using SSH.
-
Check that
/var/run/fail2ban
and/run/lock/files
directories exist:# ls -ld /run/lock/files /run/fail2ban
Note: if the command output says there is “No such file or directory” – check this article first Various actions fail in Plesk with Fail2Ban installed after server reboot: Unable to open file /run/lock/files/, There is no directory /var/run/
-
Set the correct PID file in
so it looks like this:
/etc/fail2ban/fail2ban.conf# Option: pidfile
pidfile = /var/run/fail2ban/fail2ban.pid - Restart fail2ban service:
# systemctl restart fail2ban.service