Magento – Magento 2 Gateway timeout how to resolve

cachemagento2timeoutvarnish

I have a website on Magento 2 and when I try to access the website, it's really slow and it can take up to 2 minutes to charge a page. When I try to access the admin, either it's really slow like on the website or I get the error

504 Gateway Time-out

I don't know how to fix it. It seems to be related with varnish but I didn't find anything on the net, I couldn't find the files they talked about.
Thanks for your help

Edit: When I try to access my website, I immediately get the home page with every element on it, but it keeps loading for 30 seconds.

Best Answer

A few initial checks I would make.

  1. Check your PHP settings:

Set the PHP memory limit.

https://support.magento.com/hc/en-us/articles/360034599631-PHP-settings-errors

Our detailed recommendations are:

  • Compiling code or deploying static assets, 756M
  • Installing and updating Magento components from Magento Marketplace, 2G
  • Testing, ~3-4G

Check your PHP version is correct, Magento supports PHP 7.4.0.

See: https://devdocs.magento.com/guides/v2.4/install-gde/prereq/php-settings.html#check-php-settings

  1. Ensure you have enabled your store's cache:

Either via Admin > System > (Tools) Cache Management,

Magento 2 Admin Cache Management

or via CLI:

bin/magento cache:enable
  1. Set your Magento mode to production:

Production mode also has better performance because static view files are populated in the pub/static directory and because of code compilation.

bin/magento deploy:mode:set production
Related Topic