I am getting a 503 Error randomly on my site with "Area Code is Not Set" I have not been able to track it down as it appears to be at random. The only way I can consistently get it to happen is to open 10-20 links at the same time, at least one of those pages will have the error.

The stack trace is not the same as far as I can tell between when the error is thrown that would narrow it down to an extension. Error Log here and here.

Also running "php bin/magento config:show" returns an area code not set error, none of the other CLI commands seem to do that though.

ENV: PHP 7.0.32, Nginx 1.10.2, Magento 2.2.5

  • 1
    Do you use any third party module? Maybe MSP_DevTools?
    – BartZalas
    Sep 24, 2018 at 22:02
  • I do have quite a few 3rd party modules. I have thought about disabling them one by one until I find the issue, I was hoping there would be a better way, or if anyone else has had this issue.
    – hpz937
    Sep 25, 2018 at 16:19
  • I found similar issue but it was related with third party module that was using set Area in construct function, thats why we need to find what module cause this
    – BartZalas
    Sep 25, 2018 at 17:18
  • Are you using magento enterprise with the staging module? I am seeing these exact same traces and am currently debugging. Nov 13, 2018 at 9:57

1 Answer 1


I believe this issue can be resolved by increasing your redis max_concurrency value in app/etc/env.php, try stepping it above what you have now a little. Don't use 999999 ;)

'session' =>
        'save' => 'redis',
        'redis' =>
                'max_concurrency' => '999999',

I have raised an issue with Magento (https://github.com/magento/magento2/issues/19207) as I was seeing the same thing as you on 2.1.15 EE.

The issue is hard to understand as the error handling for a redis ConcurrentConnectionsExceededException is incorrect.

public function read($sessionId)
    try {
        return parent::read($sessionId);
    } catch (ConcurrentConnectionsExceededException $e) {
        require $this->filesystem->getDirectoryRead(DirectoryList::PUB)->getAbsolutePath('errors/503.php');

By simply requiring the errors/503.php page it triggers some error handling which launches a new ObjectManager with an entirely new State config which is missing the area information. However there is no exit command issued anywhere so the rest of the request processes as normal, meaning you see this garbled Area code is not set error.

Essentially the system tried to throw one error, messed it up, and threw another error instead.

I believe you will be able to resolve this on your system by fixing the initial ConcurrentConnectionsExceededException error.

  • I upped the max_concurrency to 10 from 6 and that seems to have curbed the issue a bit although still happening, I have not tried your fix in the github issue yet, but looks to be promising.
    – hpz937
    Nov 14, 2018 at 16:29
  • The change in the github issue will only report the error correctly. if it's still occurring maybe try increasing further, see how your system handles with 15, 20, etc. Nov 14, 2018 at 16:32
  • 1
    Thanks for the solution. I changed the value from 12 to 20 for max_concurrency. It solved the issue. Dec 20, 2021 at 5:39

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.