2

Normally when you enter maintenance Mode, Magento is supposed to return a 503 Error, and redirect to a customizable page.

Right now, when I enable maintenance mode, Magento returns a 500 error, and displays the following message:

Unable to proceed: the maintenance mode is enabled. 
#0 /root/vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Bootstrap->assertMaintenance()
#1 /root/index.php(40): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#2 {main}

Nothing shows up in Magento or server logs. How can I fix this?

  • I'm hoping this gets an answer because I've always had this problem. Are you in developer mode by chance? – jamil Jan 11 '17 at 23:53
2

Probably you have developer mode enabled. If you take a look at vendor/magento/framework/App/Http.php, method catchException is trying to handle Exception

Unable to proceed: the maintenance mode is enabled.

thrown in vendor/magento/framework/App/Bootstrap.php. and in the case of developer mode it is supposed to send 500 response code. In production mode handleBootstrapErrors method redirects user to errors/503.php:

    /**
     * {@inheritdoc}
     */
    public function catchException(Bootstrap $bootstrap, \Exception $exception)
    {
        $result = $this->handleDeveloperMode($bootstrap, $exception)
            || $this->handleBootstrapErrors($bootstrap, $exception)
            || $this->handleSessionException($exception)
            || $this->handleInitException($exception)
            || $this->handleGenericReport($bootstrap, $exception);
        return $result;
    }

    /**
     * Error handler for developer mode
     *
     * @param Bootstrap $bootstrap
     * @param \Exception $exception
     * @return bool
     */
    private function handleDeveloperMode(Bootstrap $bootstrap, \Exception $exception)
    {
        if ($bootstrap->isDeveloperMode()) {
            if (Bootstrap::ERR_IS_INSTALLED == $bootstrap->getErrorCode()) {
                try {
                    $this->redirectToSetup($bootstrap, $exception);
                    return true;
                } catch (\Exception $e) {
                    $exception = $e;
                }
            }
            $this->_response->setHttpResponseCode(500);
            $this->_response->setHeader('Content-Type', 'text/plain');
            $this->_response->setBody($exception->getMessage() . "\n" . $exception->getTraceAsString());
            $this->_response->sendResponse();
            return true;
        }
        return false;
    }
    /**
     * Handler for bootstrap errors
     *
     * @param Bootstrap $bootstrap
     * @param \Exception &$exception
     * @return bool
     */
    private function handleBootstrapErrors(Bootstrap $bootstrap, \Exception &$exception)
    {
        $bootstrapCode = $bootstrap->getErrorCode();
        if (Bootstrap::ERR_MAINTENANCE == $bootstrapCode) {
            require $this->_filesystem->getDirectoryRead(DirectoryList::PUB)->getAbsolutePath('errors/503.php');
            return true;
        }
        if (Bootstrap::ERR_IS_INSTALLED == $bootstrapCode) {
            try {
                $this->redirectToSetup($bootstrap, $exception);
                return true;
            } catch (\Exception $e) {
                $exception = $e;
            }
        }
        return false;
    }
  • 2
    I am in developer mode (and can't check production mode due to some other issue). I wonder what the reasoning behind this is? Seems silly that I'd have to be in production mode to test a custom friendly 503 page – andyjv Jan 12 '17 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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