6

Recently, I have tried restarting Fail2ban and I have received an error, making it impossible to start... The full error I received from systemctl status fail2ban is as follows:

Jan 03 18:27:02 nerdofcode.com systemd[1]: fail2ban.service: Control process exited, code=exited status=255
Jan 03 18:27:02 nerdofcode.com systemd[1]: Failed to start Fail2Ban Service.
Jan 03 18:27:02 nerdofcode.com systemd[1]: fail2ban.service: Unit entered failed state.
Jan 03 18:27:02 nerdofcode.com systemd[1]: fail2ban.service: Failed with result 'exit-code'.
Jan 03 18:27:02 nerdofcode.com systemd[1]: fail2ban.service: Service hold-off time over, scheduling restart.
Jan 03 18:27:02 nerdofcode.com systemd[1]: Stopped Fail2Ban Service.
Jan 03 18:27:02 nerdofcode.com systemd[1]: fail2ban.service: Start request repeated too quickly.
Jan 03 18:27:02 nerdofcode.com systemd[1]: Failed to start Fail2Ban Service.
Jan 03 18:27:02 nerdofcode.com systemd[1]: fail2ban.service: Unit entered failed state.
Jan 03 18:27:02 nerdofcode.com systemd[1]: fail2ban.service: Failed with result 'exit-code'.

The full output of cat /var/log/fail2ban.log is:

2018-01-03 18:06:28,337 fail2ban.server         [25119]: INFO    
Exiting Fail2ban

I would appreciate any suggestions or solutions towards this issue.

Kevin Bowen
  • 20,055
  • 57
  • 82
  • 84
NerdOfCode
  • 2,608

3 Answers3

17

There is a good chance that the error has been logged to /var/log/fail2ban.log however you can also see what the problem is by running fail2ban-client -x start and you will get something descriptive.

In my case it was an exim rejectlog that did not yet exist.

Credit to @bistoco's comment on the question.

Duncanmoo
  • 2,570
0

The error was not logged in /var/log/fail2ban.log as suggested elsewhere. You better stop beforehand the fail2ban process. On systemd you do a :

sudo /usr/bin/fail2ban-client stop

For my case it wasn't even running so after that I manually started fail2ban and it finally gave me the error:

$ sudo /usr/bin/fail2ban-client stop
RROR  Failed to access socket path: /var/run/fail2ban/fail2ban.sock. Is fail2ban running?
$ sudo /usr/bin/fail2ban-client -x start
ERROR  No file(s) found for glob /var/log/apache2/*error.log
ERROR  Failed during configuration: Have not found any log file for apache-shellshock jail

I went on a corrected the apache-shellshock instructions in /etc/fail2ban/jail.local and restarted fail2ban and it worked.

iMitwe
  • 123
0

Upon a fresh installation, I faced the same issue.

I created a jail.local file in /etc/fail2ban folder:

sudo cp jail.conf jail.local

I then run this command:

sudo echo -e "[sshd]\nbackend=systemd\nenabled=true" | sudo tee /etc/fail2ban/jail.local

Output:

[sshd]
backend=systemd
enabled=true

Credit to @sebres

And I restarted it:

sudo systemctl restart fail2ban

Finally it works:

begueradj@begueradj:~$ systemctl status fail2ban.service
● fail2ban.service - Fail2Ban Service
     Loaded: loaded (/lib/systemd/system/fail2ban.service; enabled; preset: enabled)
     Active: active (running) since Sun 2025-04-13 04:16:21 UTC; 4s ago
       Docs: man:fail2ban(1)
   Main PID: 3143 (fail2ban-server)
      Tasks: 5 (limit: 9517)
     Memory: 15.2M
        CPU: 116ms
     CGroup: /system.slice/fail2ban.service
             └─3143 /usr/bin/python3 /usr/bin/fail2ban-server -xf start