Symptoms
- On a brand-new install of Plesk for Linux on an Ubuntu 24.04 server, fail2ban service does not start.
- The following information can be seen on systemctl status fail2ban
May 17 15:32:25 server.example.com systemd[1]: Starting fail2ban.service - Fail2Ban Service...
May 17 15:32:25 server.example.com systemd[1]: Started fail2ban.service - Fail2Ban Service.
May 17 15:32:25 server.example.com fail2ban-server[128927]: 2024-05-17 15:32:25,412 fail2ban.configreader [128927]: WARNING 'allowipv6' not defined in 'Definition'.
May 17 15:32:25 server.example.com fail2ban-server[128927]: 2024-05-17 15:32:25,449 fail2ban [128927]: ERROR No module named 'asynchat'
May 17 15:32:25 server.example.com systemd[1]: fail2ban.service: Main process exited, code=exited, status=255/EXCEPTION
May 17 15:32:25 server.example.com systemd[1]: fail2ban.service: Failed with result 'exit-code'.
Cause
Fail2Ban is incompatible with Python 3.12 due to a known issue:
https://bugs.launchpad.net/ubuntu/+source/fail2ban/+bug/2055114
Resolution
As a workaround, install pyasynchat:
1.Connect to the server via SSH
2.Install PIP (Package Installer for Python):
#apt install python3-pip
3.Install pyasynchat package:
#python3 -m pip install pyasynchat --break-system-packages
4.Start Fail2ban service
#systemctl start fail2ban