2FA Backup Codes not shown [solved]

Hello all


Nextcloud version _(eg, 18.0.3):
Operating system and version (eg, Ubuntu 17.04): armbian on BananaPi
Apache or nginx version (eg, Apache 2.4.25): nginx latest update
PHP version (eg, 7.1): 7.2-fpm

The issue you are facing:
I have recently installed the 2FA TOTP as well as the backup code generation app. both apps are OK, the occ:app list is providing TOTP v4.1.3 and twofactor_backupcodes v 1.7.0

The 2FA works good, user are able to login using their credentials and are being asked for their authentification code via a phone app.
What is not working at all is the display and/or the generation of the backup codes

Is this the first time you’ve seen this error? (Y/N): Y (fresh 2FA install/enabled)

Steps to replicate it:

  • If I’m pressing the button “generate backup code” --> nothing is being displayed
  • If I’m later pressing the button “renew backup codes” --> nothing is being displayed
  • I’m seeing some info displayed on the top right out of the user button something like “backup code generation failed”

The output of your Nextcloud log in Admin > Logging:

I don’t know if this has something to do with it but in the log I’m seeing the following error message: Doctrine\DBAL\Exception\DriverException:
An exception occurred while executing 'SELECT * FROM oc_comments WHERE (message COLLATE utf8mb4_general_ci LIKE ?) AND (object_type= ?) ORDER BYcreation_timestampDESC,id DESC LIMIT 100' with params ["%%", "files"]: SQLSTATE[42000]: Syntax error or access violation: 1253 COLLATION 'utf8mb4_general_ci' is not valid for CHARACTER SET 'utf8'

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):


The output of your Apache/nginx/system log in /var/log/____:


I have tried a bit with the occ command and looked into the backup code app folder on the HDD but nothing obvious for me
Any idea what I can do?

Thank you!!

Dear all,

no idea from the community? if I can’t get the backup codes I would de-install the TOTP app again as the risk is always present of loosing the primary 2FA generation device and then be locked out.

Any idea from the community what I can do?

Thanks a lot!

I also use the TOTP app had a problem similar to this where the 2FA backup codes would not appear. After trying a few times, I realized that it just takes a while to generate them. I just waited a minute and they eventually showed up. I’m kind of surprised there isn’t a loading icon or anything to indicate this.

Also consider using the Two Factor Admin Support app. This allows a NC admin to generate a code for someone who has lost their TOTP generator. That way they can get in their account and set up a new one without ever turning TOTP off.

Hi all,

I recently updated my NC to 19.3 but the problem with the not shown Backup Codes still exist.
The same behaviour if I’m logging in as normal user or as admin --> something is happening (can see the circle running next to “re-generate Backup codes” button but nothing is happening except the small hint on top right next to the user button.
Nothing being shown in the NC log files.

Appreciating any help!

How long do you wait? Does it ever stop?
What is the hardware your Nextcloud runs on?

Based on this it’s an ARM CPU

I’d give it a minute or more to generate those codes…

Hi Henry,
thanks for quick help!
I can wait “forever” nothing is happening. The “running circle” stops after~ 1 minute and the message on top right is being shown.
If I’m updating (F5) the browser page, a message is displayed above the “renew Backup codes” button, tellling me that backup codes have been generated… but I can’t see them. Are they stored somewhere else?

Not that I know…
Have you tried different browsers? Sounds like a rendering issue…

Hi Henry, just tried a different browser (Edge) and the same behaviour.
Something is happening in the background but I can’t see the results.
Any other idea?

I got the answer now while looking into the nginx error log:
The connection timed out between the server and the device.
While adding:
proxy_connect_timeout 120s;
proxy_send_timeout 120s;
proxy_read_timeout 120s;
fastcgi_send_timeout 120s;
fastcgi_read_timeout 120s;
to nginx.conf and reloading the nginx configuration (systemctl reload nginx) and then re-generating the Backup Codes.
Now the codes are shown for the respective user.
Txs Henry, that you pointed me to the right direction stating it might be a rendering problem --> browser/webserver --> nginx.log :smiley: