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.
Have you tried increasing the max_input_vars the same way you did with memory limit?
max_input_vars
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:
Increase Server Resources:
Magento Specific Optimizations:
Server Configuration:
Magento Application Optimization:
Paco Abella
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.