Service Temporarily Unavailable – Magento 2


Problem:
Service Temporarily Unavailable is showing on every page of my website after upgrade or adding an extension:

Solution:

Magento 2 maintenance mode file has the name .maintenance.flag (with the leading dot) and is located in the var folder.
But HTTP 503 code response can have different causes. For example, the cause could be a webserver misconfiguration or file/permissions/ownership errors.

In lots of cases, after installing a new extension and recompiling Magento 2 code, you need to set file and folder permissions again.

After running these commands through SSH:

php bin/magento setup:upgrade

php bin/magento setup:di:compile

You then need to reset the file permissions and reset file ownership by running these commands through SSH:

find . -type f -exec chmod 644 {} \; // 644 permission for files

find . -type d -exec chmod 755 {} \; // 755 permission for directory

find ./var -type d -exec chmod 777 {} \; // 777 permission for var folder

find ./pub/media -type d -exec chmod 777 {} \;

find ./pub/static -type d -exec chmod 777 {} \;

chmod 777 ./app/etc

chmod 644 ./app/etc/*.xml

chown -R 10000:1004 .

chmod u+x bin/magento

That should fix the “Service Temporarily Unavailable” issues.

Sometimes you might need to run this command more than once:

chown -R 10000:1004 .

0