cancel
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.

3 REPLIES 3

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?

max_input_vars
Founder at https://agency418.com

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

https://magento-specialist.com/

Re: 504 gateway timeout while saving category url key

A "504 Gateway Timeout" error while saving a category URL key in Magento 2 can occur due to several reasons, such as server misconfiguration, long-running processes, or database issues. Here are some steps to help troubleshoot and resolve the issue:

1. Increase PHP and Server Timeout Limits

The issue might happen because the server takes too long to process the request. You can try increasing the timeout limits for PHP, Nginx, or Apache:

PHP Configuration (php.ini): Adjust the following settings:

max_execution_time = 300
max_input_time = 300
memory_limit = 512M
Nginx Configuration: Add or increase the following timeout settings in your Nginx configuration file (nginx.conf):

proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
Apache Configuration: Add or increase the following directives in your Apache configuration (httpd.conf):

Timeout 600

2. Check for Long-Running Processes

Sometimes, Magento needs to reindex URLs or regenerate cache, which can take longer than expected, especially if you have a large number of categories or products.

Reindex Manually: Try running the following reindex command manually:


php bin/magento indexer:reindex
Clear Cache: Clearing cache might help resolve any cache-related issues:


php bin/magento cache:flush


3. Database Lock Issues

If there is a lock on the database that prevents saving the category, check for database locks and resolve them.

Check MySQL Process List: Run the following command to check for locked queries:


SHOW FULL PROCESSLIST;
You can then investigate and kill any problematic queries.

Optimize Database: It might help to optimize your database tables, especially url_rewrite and catalog_category_entity. 


4. Examine Logs

Check the following logs for any specific errors that could provide more insight:

Magento Logs: Located in var/log/exception.log and var/log/system.log.
Web Server Logs: Check Nginx or Apache error logs for relevant details. 


5. Check for URL Rewrite Conflicts

There might be a conflict with an existing URL key. Ensure the new URL key you're trying to save doesn't conflict with an already existing category or product URL key.

Check the url_rewrite table in the database for any existing records with the same URL key:


SELECT * FROM url_rewrite WHERE request_path = 'your-url-key';

6. Upgrade PHP / Magento

Sometimes these issues can also arise due to older versions of PHP or Magento. Ensure you are using a supported version of PHP and that your Magento installation is up to date.

Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.