Answers.Body: <p>I've found this question through search. </p>
  
  <p>I did not perform any update which broke my controllers, but I was unable to access them publicly.</p>
  
  <p>My solution was adding <code>$allowAnonymous = true;</code> to my controller:</p>
  
  <pre class="lang-php prettyprint-override"><code>
  class MyController extends \craft\web\Controller
  {
      public $allowAnonymous = true;
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-18T00:12:11.733Z
Answers.LastActivityDate: 2020-05-18T00:12:11.733Z
Answers.UserDisplayName: jakub_jo
Answers.Body: <p>Figured out what was going on here. Somehow during updates, the system variable in my config got wiped out. I fixed the 503 by manually setting: <code>isSystemLive =&gt; true</code> in config/general.php</p>
  
  <p>To fix the rest of the system settings, I had to copy that variable from my local environment into the info table in the DB.</p>
  
  <p>Still have no idea why it broke in the first place but things seem to be working now.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-03T13:33:10.977Z
Answers.Text: Do you have a database backup from before the update? If you restore it, are you able to reproduce the same issue?
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-03T17:13:35.500Z
Answers.Text: I just tried the upgrades again with a backup from v 3.0.30.1
  
  I was able to reproduce the 503 error. Once I went into the control panel and followed the "databases needs to be updated" prompt, the issue was resolved though.
  
  When I initially made the upgrades, I went into the control panel and ran them from the upgrades utility. It segmented the upgrades into multiple runs, so possibly something was overwritten by running so many upgrades at once. Hard to reproduce the exact scenario.
Answers.UserDisplayName: slander
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-03T00:18:04.063Z
Answers.LastActivityDate: 2020-01-03T00:18:04.063Z
Answers.UserDisplayName: slander
Answers.Body: <p>Are you routing to a custom controller action? If so, make sure that its <code>init()</code> method is calling <code>parent::init()</code>.</p>
  
  <pre class="lang-php prettyprint-override"><code>public function init()
  {
      parent::init();
  
      // custom logic here
      // ...
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-02T22:51:56.840Z
Answers.Text: That's a good thing to know!
  
  
  But no, this site doesn't have any custom modules or any extra defined routes so I'm pretty sure that isn't the issue.
Answers.UserDisplayName: slander
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-02T23:07:17.330Z
Answers.Text: Any plugins installed that could be taking over front-end routing? Try disabling them.
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-02T23:17:30.773Z
Answers.Text: That was my thought too, which dug up more errors. Apparently all of my plugins were uninstalled while updating. Now when I try to re-install them I'm getting "no plugin exists with handle XXXX". I'm assuming this is related somehow to the overall error
Answers.UserDisplayName: slander
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-02T23:47:47.340Z
Answers.Text: Ok fixed the plugin issue (license was set back to solo during upgrade and switching back to pro fixed it). I disabled the plugins and I'm still getting the 503 errors.
Answers.UserDisplayName: slander
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-02T22:28:03.977Z
Answers.LastActivityDate: 2020-01-02T22:28:03.977Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>Working on an outdated client project and updated craft on staging from 3.0.30.1 to 3.3.19</p>
  
  <p>I'm getting 503 errors (site temporarily unavailable) when trying to visit any page on the site -- but only for <em>logged out</em> users. Once I log in, everything works normally.</p>
  
  <p>I've checked that the DB connection is working correctly. When I performed the updates, I got a dialog from Craft to update my database and performed it so the schemas should be up to date. </p>
  
  <p>The stack trace shows where the error occurred but I'm stumped as to why it's happening or how to fix it:</p>
  
  <p>From <code>vendor/craftcms/cms/src/web/Controller.php</code> (starts line 157):</p>
  
  <pre><code>        if (!($test &amp; $allowAnonymous)) {
              // If this is a CP request, make sure they have access to the CP
              if ($request-&gt;getIsCpRequest()) {
                  $this-&gt;requireLogin();
                  $this-&gt;requirePermission('accessCp');
              } else if (Craft::$app-&gt;getUser()-&gt;getIsGuest()) {
                  throw new ServiceUnavailableHttpException();
              }
  </code></pre>
  
  <p>The exception at the bottom of this check is what is thrown and causing the error, but why would a visit to the homepage be detected as a CP request? I'm assuming CP means control panel.</p>
  
  <p>Any ideas?</p>
  
Tags: <updates>
Title: Updating Craft to 3.3.19 gives 503 error only for logged-out users
ThreadText: # Updating Craft to 3.3.19 gives 503 error only for logged-out users
  
  (Asked by: username_0 on 2020-01-02)
  
  Working on an outdated client project and updated craft on staging from 3.0.30.1 to 3.3.19
  
  I'm getting 503 errors (site temporarily unavailable) when trying to visit any page on the site -- but only for *logged out* users. Once I log in, everything works normally.
  
  I've checked that the DB connection is working correctly. When I performed the updates, I got a dialog from Craft to update my database and performed it so the schemas should be up to date.
  
  The stack trace shows where the error occurred but I'm stumped as to why it's happening or how to fix it:
  
  From `vendor/craftcms/cms/src/web/Controller.php` (starts line 157):
  
  ```
          if (!($test & $allowAnonymous)) {
              // If this is a CP request, make sure they have access to the CP
              if ($request->getIsCpRequest()) {
                  $this->requireLogin();
                  $this->requirePermission('accessCp');
              } else if (Craft::$app->getUser()->getIsGuest()) {
                  throw new ServiceUnavailableHttpException();
              }
  
  ```
  
  The exception at the bottom of this check is what is thrown and causing the error, but why would a visit to the homepage be detected as a CP request? I'm assuming CP means control panel.
  
  Any ideas?
  
  **Tags:** updates
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2020-05-18. Score: 2
  
  I've found this question through search.
  
  I did not perform any update which broke my controllers, but I was unable to access them publicly.
  
  My solution was adding `$allowAnonymous = true;` to my controller:
  
  ```php
  
  class MyController extends \craft\web\Controller
  {
      public $allowAnonymous = true;
  }
  
  ```
  
  
  ---
  
  ### Answer by username_0 on 2020-01-03. Score: 1
  
  Figured out what was going on here. Somehow during updates, the system variable in my config got wiped out. I fixed the 503 by manually setting: `isSystemLive => true` in config/general.php
  
  To fix the rest of the system settings, I had to copy that variable from my local environment into the info table in the DB.
  
  Still have no idea why it broke in the first place but things seem to be working now.
  
  > **Comments:**
  > **username_2**: Do you have a database backup from before the update? If you restore it, are you able to reproduce the same issue?  
  > **username_0**: I just tried the upgrades again with a backup from v 3.0.30.1  I was able to reproduce the 503 error. Once I went into the control panel and followed the "databases needs to be updated" prompt, the issue was resolved though.  When I initially made the upgrades, I went into the control panel and ran them from the upgrades utility. It segmented the upgrades into multiple runs, so possibly something was overwritten by running so many upgrades at once. Hard to reproduce the exact scenario.  
  
  ---
  
  ### Answer by username_2 on 2020-01-02. Score: 1
  
  Are you routing to a custom controller action? If so, make sure that its `init()` method is calling `parent::init()`.
  
  ```php
  public function init()
  {
      parent::init();
  
      // custom logic here
      // ...
  }
  
  ```
  
  > **Comments:**
  > **username_0**: That's a good thing to know!   But no, this site doesn't have any custom modules or any extra defined routes so I'm pretty sure that isn't the issue.  
  > **username_2**: Any plugins installed that could be taking over front-end routing? Try disabling them.  
  > **username_0**: That was my thought too, which dug up more errors. Apparently all of my plugins were uninstalled while updating. Now when I try to re-install them I'm getting "no plugin exists with handle XXXX". I'm assuming this is related somehow to the overall error  
  > **username_0**: Ok fixed the plugin issue (license was set back to solo during upgrade and switching back to pro fixed it). I disabled the plugins and I'm still getting the 503 errors.  
  
  ---
  
  