My Nextcloud 29.0.3 runs on Debian 11
with Python 3.9.2
for safety reasons on this server running Fail2ban.
some Nextcloud apps wants a newer Version of python (3.12) but after i installed the new python Version.
fail2ban will not start, so i switched back to python3.9.2
Afaik Nextcloud has no dependency on Python and fail2ban is not part of the Nextcloud package. You should address all fail2ban related questions in a Debian or fail2ban forum.
Perhaps try with Debian 12, perhaps they have a newer package of fail2ban that supports python 3.12. But normally the native debian packages are created in a way that they work well together.
I am not sure if in debian, you could install easily other python environments (for this specific app).