Showing results for 
Search instead for 
Did you mean: 

504 gateway timeout while saving category url key

504 gateway timeout while saving category url key

We are getting a 504 gateway timeout while saving the url key of a category having around 185000 products, we have deleted the url_rewrite table completely, still facing the issue. Our magento version is 2.4.5-p1. Memory limit is set to -1.


Re: 504 gateway timeout while saving category url key

Have you tried increasing the max_input_vars the same way you did with memory limit?

Founder at

Re: 504 gateway timeout while saving category url key

HI @yashwankhadf9a 


A 504 Gateway Timeout error in Magento, particularly when dealing with a large number of products or extensive operations like updating a category with a substantial number of products, can be challenging. This error typically indicates that the server is taking too long to respond, possibly due to a resource-intensive process. Here are some steps to troubleshoot and resolve this issue in your Magento 2.4.5-p1 environment:

  1. Increase Server Resources:

    • Time-Out Settings: Check and increase the time-out settings of your web server (e.g., Apache or Nginx) and PHP. For Nginx, you might need to adjust the proxy_read_timeout setting. For Apache, look into the TimeOut directive.
    • PHP Execution Time: Increase the max_execution_time in your PHP configuration (php.ini) to ensure the script has sufficient time to complete.
  2. Magento Specific Optimizations:

    • URL Rewrite Optimization: Given that you've already cleared the url_rewrite table, consider implementing a more efficient approach to URL rewrites. There are third-party extensions available that optimize the way Magento handles large numbers of URL rewrites.
    • Indexing: Run a full reindex from the command line using bin/magento indexer:reindex to ensure all indexes are up to date. This can sometimes resolve issues related to large-scale data changes.
  3. Server Configuration:

    • Check Server Logs: Review the server error logs for any specific errors that could be contributing to the time-out. These logs can offer valuable insights into what might be causing the issue.
    • Memory Allocation: Even though the memory limit is set to -1, ensure that the server has enough physical memory available. Magento can be resource-intensive, and insufficient memory can lead to time-outs.
  4. Magento Application Optimization:

    • Caching: Make sure that Magento's caching is properly configured and enabled to improve performance.
    • Background Tasks: Consider executing such large operations as background tasks or during off-peak hours to minimize the impact on your server's performance.


Paco Abella