Unable to login as admin after enabling read only mode

AI-generated summary

Gulshan_Kumar was unable to log in as admin after enabling read-only mode via the admin panel, encountering the error “Login is disabled while the site is in read only mode.” itsbhanusharma initially suggested trying /u/admin-login, but that also failed with a read-only error Gulshan_Kumar. itsbhanusharma then provided links to meta.discourse.org threads and advised not to log out after enabling read-only mode Gulshan_Kumar. Confused, Gulshan_Kumar asked if code editing was needed. itsbhanusharma clarified no code changes were required and gave SSH commands: cd /var/discourse, ./launcher enter app, rails c, then Discourse.disable_readonly_mode(Discourse::USER_READONLY_MODE_KEY). After an initial failed attempt Gulshan_Kumar, itsbhanusharma confirmed the correct syntax should return a boolean. Gulshan_Kumar reported it still didn’t work, but eventually confirmed that using the full command with Discourse::USER_READONLY_MODE_KEY succeeded Gulshan_Kumar. The issue was resolved, and admin login was restored.

My site says “Login is disabled while the site is in read only mode?” so I cannot log in:

Visit yoursite.com/u/admin-login i.e. help.gulshankumar.net/u/admin-login and then try to log in if that works?

Hi,

Thanks for the response. I tried, it says -

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

Depending upon how you enabled the read only mode, here is some help:

or

I had enabled read-only mode from admin area from where we do backup.

Second option I suggested above should work for you. Please do not log out the next time you put your forum into read only mode.

Ps: Try searching before posting a new query, You may find your solution into a similar question asked by someone else.

Sorry, I couldn’t understand above written steps. Do I need to edit any code? :thinking:

You don’t have to edit anything. Just ssh into your discourse server and do the following:

cd /var/discourse
./launcher enter app
rails c
Discourse.disable_readonly_mode(Discourse::USER_READONLY_MODE_KEY)

I hope everything is fine.

Try again. You may have entered the commands incorrectly. It should return like this:

I replicated above steps. Still, site is showing in the read-only mode.

image

Discourse.disable_readonly_mode
Not working.

Discourse.disable_readonly_mode(Discourse::USER_READONLY_MODE_KEY)
Working.

Thanks a lot. Now I am able to login.