1

Topic: Fail2ban Log Filled With Command Not Found Errors + Fix

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.7.4
- Deployed with iRedMail Easy or the downloadable installer? No
- Linux/BSD distribution name and version: Debian 12
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
Snippet:
2025-07-17T22:01:33.958862+00:00 mail fail2ban.utils[403]: ERROR 7fe3f54b2790 -- returned 127
2025-07-17T22:01:33.958916+00:00 mail fail2ban.utils[403]: INFO HINT on 127: "Command not found".  Make sure that all commands in '/usr/local/bin/fail2ban_banned_db start pregreet'
====

Did a fresh install yesterday and noticed errors in Fail2ban log. Found a path error to bash in line 1 of /usr/local/bin/fail2ban_banned_db.

Stopped fail2ban service. Changed 1st line of fail2ban_banned_db to #!/bin/bash. Restarted fail2ban. Logs are clean now.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Fail2ban Log Filled With Command Not Found Errors + Fix

Does your server have /usr/bin/env?

3

Re: Fail2ban Log Filled With Command Not Found Errors + Fix

Yes sir

4

Re: Fail2ban Log Filled With Command Not Found Errors + Fix

My apologies, I saw the previous issue pavel.kasparak reported about fail2ban. I did the fix you recommended. It cleaned up the logs but I noticed an error in consecutive lines during fail2ban startup:

fail2ban.utils[409]: ERROR 7f36808743f0 -- exec: /usr/local/bin/fail2ban_banned_db start sshd

fail2ban.utils[409]: ERROR 7f36808743f0 -- stderr: "ERROR 2002 (HY000): Can't connect to server on '127.0.0.1' (115)"

fail2ban.utils[409]: ERROR 7f36808743f0 -- returned 1

fail2ban.actions[409]: ERROR Failed to start jail 'sshd' action 'banned_db': Error starting action Jail('sshd')/banned_db: 'Script error'

5

Re: Fail2ban Log Filled With Command Not Found Errors + Fix

Seems failed to connect to SQL server.
Does it failed every time when it blocks an IP?