cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 works perfectly in developer mode but not in production

Magento 2 works perfectly in developer mode but not in production

 

I have migrated a magento 2 install from one server to another. Copied the files, imported db etc. and in developer mode it works fine, all the pages display with the products, the admin portal works etc.

As soon as I put it into production mode nothing works at all. I have tried numerous suggestions the main ones being -

 

  1. after enabling production mode -
  • bin/magento setup:upgrade
  • bin/magento setup:di:compile php
  • bin/magento cache:clean php
  • bin/magento cache:flush
  • bin/magento setup:static-content:deploy -f en_US en_GB
  1. after enabling production mode -

clean the cache and then run "composer install" in the Magento root directory which obviously you shouldn't have to do but it apparently worked for some people.

 

All I get is an HTML 500 error when in production for both the site and the admin login page. There is nothing in the apache error log file.

 

I am not experienced with Magento but when in developer mode I was looking at the MAGEROOT/var/log files which were quite helpful. But when in production mode nothing seems to get added to the log files.

 

Can someone suggest how I can go about debugging this ?

 

Any and all suggestions welcome.

 

Thanks

2 REPLIES 2

Re: Magento 2 works perfectly in developer mode but not in production

Hello!
try remove paste generated

rm -rf generated/*

After run

bin/magento setup:di:compile

if persist check ur permissions folders.

 


Verify if is maintenance mode:

to disable maintenance

bin/magento maintenance:disable


U can verify too the app/etc/env.php, follow the doc for creating corretely the env.
https://experienceleague.adobe.com/en/docs/commerce-operations/configuration-guide/files/config-refe...


 

Re: Magento 2 works perfectly in developer mode but not in production

  1. Check Permissions: Verify file and directory permissions.
  2. Clear Files: Remove generated and static content.
  3. Disable Maintenance: Ensure it’s off.
  4. Verify env.php: Check database settings.
  5. Enable Logging: Turn on error reporting.
  6. Review Server Settings: Check Apache/Nginx config.
  7. Use CLI: Run commands via the command line.
  8. Check PHP: Ensure the correct version and extensions.

Finally, check var/log for errors.