# Discourse stuck in maintenance mode

**URL:** https://meta.discourse.org/t/discourse-stuck-in-maintenance-mode/233602
**Category:** Self-hosting
**Created:** [July 22, 2022, 1:46am UTC](https://meta.discourse.org/t/discourse-stuck-in-maintenance-mode/233602 "2022-07-22T01:46:44Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![41821](https://avatars.discourse-cdn.com/v4/letter/4/c4cdca/32.png) [@41821](https://meta.discourse.org/u/41821)
#### Post date: [July 22, 2022, 1:46am UTC](https://meta.discourse.org/t/discourse-stuck-in-maintenance-mode/233602/1 "2022-07-22T01:46:44Z")

</div>

Hello, my discourse server is stuck in maintenance mode.  
I have left it in maintenance mode for several months on purpose, I’ve upgraded to many versions since initially setting it to maintenance mode.

My session has expired and I’ve been logged out, now I can’t log back in.

I can SSH to the discourse server.  
I have tried the following steps:

1. SSH to discourse server
2. navigate to `/var/discourse`/
3. run: `./launcher enter app`
4. run `rails c`

I have tried several things to disable maintenance mode here.

```plaintext
[1] pry(main)> 
[2] pry(main)> 
[3] pry(main)> Discourse.disable_readonly_mode(Discourse::READONLY_MODE_KEY)
=> true
[4] pry(main)> Discourse.disable_readonly_mode
=> true

```

When I shift focus away from SSH and onto my web browser, I can see that the maintenance mode banner goes away.

then a few seconds it comes back again.

I’ve referenced these docs already:

> [@Stuck in 'Read Only' Mode](https://meta.discourse.org/t/stuck-in-read-only-mode/42820):
>
> Hi all, My site is suddenly in ‘read only’ mode, and I don’t know why. [chathamhouse.sandbaggernews.com](http://chathamhouse.sandbaggernews.com) A friend helped me set up Discourse, but unfortunately he’s left town for a Linux conference in Seattle stuck_out_tongue I’m trying to present this site to my professors tomorrow night. Really don’t know where to begin. Thanks so much, Stuck.

> [@How can Admin login while Read-only mode is enabled on multisite?](https://meta.discourse.org/t/how-can-admin-login-while-read-only-mode-is-enabled-on-multisite/23976):
>
> I did restore on my secondsite(multisite), but Read-only mode is enabled. How can I login? or How can I turn off Read-only mode? I tried: ./launcher enter app discourse disable\_readonly But nothing’s changed. (I tried ./launcher rebuild app also)

please help

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [July 22, 2022, 5:13am UTC](https://meta.discourse.org/t/discourse-stuck-in-maintenance-mode/233602/2 "2022-07-22T05:13:56Z")

</div>

Someone in the first linked topic had some luck with stopping and then restarting the container. Could that be worth a try?

---

<div class="post-metadata">

### Author: ![41821](https://avatars.discourse-cdn.com/v4/letter/4/c4cdca/32.png) [@41821](https://meta.discourse.org/u/41821)
#### Post date: [July 22, 2022, 5:31am UTC](https://meta.discourse.org/t/discourse-stuck-in-maintenance-mode/233602/3 "2022-07-22T05:31:57Z")

</div>

thanks for the suggestion. Unfortunately this hasn’t helped me ☹

I ran

```plaintext
docker ps
docker kill app
docker start app

```

One thing that’s interesting is I’ve also tried to manually enable read only mode:  
eg:

```plaintext
[8] pry(main)> Discourse.enable_readonly_mode
=> true
[9] pry(main)> Discourse.disable_readonly_mode
=> true
[10] pry(main)> 

```

Upon doing this, I noticed the banner comes back and I can’t even click the login button because it says `Login is disabled while the site is in read only mode.` and I also see the banner that says:

```plaintext
This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

```

when I call `disable_readonly_mode` again, the maintenance mode banner goes away, and I can click the login button. Discourse even hands me over to the authentication sso provider.

However, when I’m redirected back to discourse, I get a whole page saying “The site is in read only mode. Interactions are disabled.”

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [July 22, 2022, 6:18am UTC](https://meta.discourse.org/t/discourse-stuck-in-maintenance-mode/233602/4 "2022-07-22T06:18:59Z")

</div>

I’ve done a bit of digging and, while I haven’t landed on a fix as yet, it seems the `/u/admin-login` link will bypass read\_only, and allow you to still login:

> [@Log back in as admin after locking yourself out with read-only mode or an invalid SSO configuration](https://meta.discourse.org/t/log-back-in-as-admin-after-locking-yourself-out-with-read-only-mode-or-an-invalid-sso-configuration/89605/1):
>
> You’ll be sent an email with a log-in link that circumvents SSO and read-only mode.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [July 22, 2022, 7:16am UTC](https://meta.discourse.org/t/discourse-stuck-in-maintenance-mode/233602/5 "2022-07-22T07:16:31Z")

</div>

@41821 Can you try `Discourse.disable_readonly_mode(Discourse::USER_READONLY_MODE_KEY)`

---

<div class="post-metadata">

### Author: ![Ori\_Pekelman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ori_pekelman/32/124402_2.png) [@Ori\_Pekelman](https://meta.discourse.org/u/Ori_Pekelman)
#### Post date: [August 4, 2022, 10:59am UTC](https://meta.discourse.org/t/discourse-stuck-in-maintenance-mode/233602/7 "2022-08-04T10:59:57Z")

</div>

Nothing I did was able to get me out of the state.  
After `Discourse.disable_readonly_mode(Discourse::USER_READONLY_MODE_KEY)` it goes to R/W for a second and reverts back to R/O just afterwards. Nothing discernible in logs. Even flushing Redis doesn’t help. Nor clearing the redis keys by hand.

This is very likely a bug as reverting 2.8.7 to 2.8.3 (which was my previous functional version) corrected the issue.

I tried going through the code to figure out where the bug was introduced, but couldn’t actually figure it out.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [August 10, 2022, 1:54am UTC](https://meta.discourse.org/t/discourse-stuck-in-maintenance-mode/233602/8 "2022-08-10T01:54:25Z")

</div>

Is this a self hosted site? Flushing Redis should clear everything up as the readonly logic is entirely dependent on setting the right Redis keys.
