1

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?

3 Answers 3

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:


class MyController extends \craft\web\Controller
{
    public $allowAnonymous = true;
}
1

Are you routing to a custom controller action? If so, make sure that its init() method is calling parent::init().

public function init()
{
    parent::init();

    // custom logic here
    // ...
}
4
  • 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.
    – slander
    Commented Jan 2, 2020 at 22:51
  • Any plugins installed that could be taking over front-end routing? Try disabling them. Commented Jan 2, 2020 at 23:07
  • 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
    – slander
    Commented Jan 2, 2020 at 23:17
  • 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.
    – slander
    Commented Jan 2, 2020 at 23:47
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.

2
  • Do you have a database backup from before the update? If you restore it, are you able to reproduce the same issue? Commented Jan 3, 2020 at 13:33
  • 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.
    – slander
    Commented Jan 3, 2020 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.