Log back in as admin after locking yourself out with read-only mode or an invalid SSO configuration

If you’ve locked yourself out of your Discourse instance with an invalid SSO configuration, append /u/admin-login to the end of your forum’s root URL:

https://forum.example.com/u/admin-login

This will take you to an admin login page:

You’ll be sent an email with a log-in link that circumvents SSO and read-only mode. Do note however that if you have 2FA enabled you’ll still have to enter your auth code.

Alternative (requires console access)

Disable SSO

cd /var/discourse
./launcher enter app
rails c
irb > SiteSetting.enable_discourse_connect = false
irb > SiteSetting.enable_local_logins = true
irb > exit
exit

Disable read-only mode

cd /var/discourse
./launcher enter app
rails c
irb > Discourse.disable_readonly_mode(Discourse::USER_READONLY_MODE_KEY)
irb > exit
exit
18 Likes

Hi, I can’t access to my forum.

I have enabled read-only mode but now I can’t access to admin.

When I go to “/u/admin-login” and I insert my admin email, I receive this error:

{“errors”:[“The site is in read only mode. Interactions are disabled.”],“error_type”:“read_only”}

And also via console access it doesn’t work :slightly_frowning_face:

How can I resolve?

Thank you in advance

1 Like

I think you can run this in the rails console to turn it off: