Can't login to a new installation after restoring backup

UPDATE: I was able to do it by following ChatGPT’s instructions:

:white_check_mark: Step 1: SSH into your server

ssh your-user@your-server

:white_check_mark: Step 2: Enter the Discourse app container

cd /var/discourse
./launcher enter app

:white_check_mark: Step 3: Create or reset the admin user’s password

This step ensures you can log in with a known password.

rake admin:create
  • When prompted, enter the email address of the admin from the backup (e.g. admin@forum.example.com).
  • Enter a new password.
  • Type Y when asked to grant admin privileges (even if the user already is an admin — it won’t hurt).

:white_check_mark: Step 4: Open the Rails console

rails c

:white_check_mark: Step 5: Find the user by email

Replace the email with the one you’re resetting:

user = User.find_by_email("admin@forum.example.com")

You should see some output showing the user object.


:white_check_mark: Step 6: Disable 2FA for that user

user.user_second_factors.destroy_all

This deletes all 2FA keys associated with that user — without affecting anyone else.


:white_check_mark: Step 7: Exit the console and container

exit

:white_check_mark: Step 8: Log in via the web

Go to your Discourse site in the browser and log in with:

  • Email: admin@forum.example.com
  • Password: the one you set in Step 3
  • 2FA: will no longer be required
1 Like