504 gateway time-out error when saving a category with 1k+ products
This article suggests a solution for the timeout issue when performing operations on large categories (1,000+ products).
Note: This issue has been fixed in version 2.4.7.
Description description
Environment
- Adobe Commerce on cloud infrastructure 2.3.3
- Adobe Commerce on-premises 2.3.3
- Magento Open Source 2.3.3
Issue/Symptoms
Prerequisites: The Stores > Configuration > CATALOG > Catalog > Use Categories Path for Product URLs option is set to Yes for your store view.
Steps to reproduce:
- In the Commerce Admin, go to Catalog
>Categories. - Open a large category, like more than 1000 assigned products.
- Add a product to the category.
- Click Save Category.
Expected result:
The category is saved successfully.
Actual result:
After five minutes of the saving process, the 504 gateway timeout error page appears.
Root cause
The process takes longer than the server’s configured timeout.
Resolution resolution
Disabling the Generate “category/product” URL Rewrites option will remove all category/product URL rewrites from the database and significantly decrease the time required for the operations with big categories.
WARNING: Turning this option off will result in permanent removal of category/product URL rewrites without the ability to restore them.
To disable the Generate “category/product” URL Rewrites option:
- In the Commerce Admin, navigate to Stores
>Configuration>CATALOG>Catalog. - In the top left corner of the configuration page, in the Scope field, set your configuration scope to Default Config.
- Set Generate “category/product” URL Rewrites to No.
- Click Save Config.
- Clean cache by running
bash bin/magento cache:cleanor in the Commerce Admin under System>Tools>Cache Management.
Now you can proceed to adding products to categories, or moving categories with a large number of products, and these operations will take much less time and should not cause a timeout.