When I run:sudo php bin/magento deploy:mode:set production

Then i received

Command returned non-zero exit code: /usr/bin/php7.0 -f /var/www/html/magento/bin/magento setup:di:compile

  • @Rakesh Jesadiya, I think the question is not duplicate.
    – abu abu
    Commented Aug 19, 2017 at 10:22

1 Answer 1


I resolved this issue

Run these commands:

1. sudo php bin/magento maintenance:disable
2. clear cache
3. sudo chmod 777 var* -R
4. sudo chmod 777 pub* -R
  • in my case, it was giving this error due to memory, so I run following command php -dmemory_limit=1G bin/magento deploy:mode:set production
    – Alam Zaib
    Commented Jul 24, 2021 at 11:20

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