WooCommerce import error: "504 Gateway Timeout" & Execution Time Exceeded
Applies to the built-in WooCommerce CSV importer (Products → Import). Verified against WooCommerce 11.1.2 (on WordPress 7.1.2).
Which cause is yours?
| What you observe | Most likely cause |
|---|---|
| Import halts after exactly 30 or 60 seconds with an HTTP 504 screen | 1. Monolithic catalog file exceeds server limits |
| Progress bar stalls indefinitely on rows containing multiple image URLs | 2. Synchronous image downloading & thumbnail resizing |
| Fatal error: "Allowed memory size exhausted" or execution timeout in logs | 3. Low PHP max_execution_time or memory_limit |
| Catalog has 20,000+ records and web browser tabs keep disconnecting | 4. Browser HTTP interface unsuited for massive catalog |
1. Monolithic files: Split into variation-safe batches (≤ 500 rows)
The built-in WooCommerce CSV importer runs via AJAX requests in chunks of 30 records by default. However, when processing a single monolithic file with thousands of rows, database transactions slow down, database locks accumulate, and any transient delay triggers an HTTP 504 Gateway Timeout (or Cloudflare Error 524).
The danger of manual splitting: If you manually cut a large CSV into multiple files using Excel or Google Sheets, you will inevitably split a variable parent product into File 1 while its child variation rows land in File 2. When File 2 is imported, WooCommerce cannot find the parent, producing orphaned variations and corrupted product data.
Fix: Partition your catalog into sequential batches of up to 500 records where parents and all their child variations are strictly kept together in the same file.
catalog-part-01.csv # Max 500 records: complete product families (parents first) catalog-part-02.csv # Max 500 records: next set of complete product families IMPORT-ORDER.txt # Sequential import checklist to ensure zero missing parents
Split large catalogs into variation-safe batches automatically
Drop your CSV or Excel file into CatalogDock. The free in-browser engine inspects your catalog and generates variation-safe ZIP batches (up to 500 records each) that never separate parents from their variations, complete with an import checklist.
Open the free checker →Runs in your browser · No files uploaded · Never connects to your store
2. Image downloading: The biggest hidden bottleneck
By default, when WooCommerce encounters an image URL in the Images column, it performs two heavy operations synchronously inside the import request:
- Downloads the full-resolution image from the remote server over HTTP.
- Generates 4 to 6 WordPress thumbnail sizes (thumbnail, medium, large, WooCommerce single, WooCommerce gallery).
If a 30-product batch contains 3 images per product, your server must download 90 files and generate over 450 thumbnail files within a single 30-second execution window. On shared hosting, this almost always causes a 504 timeout.
Fix options:
- Pre-upload via FTP/SFTP: Upload your product images directly to
wp-content/uploads/, then reference their filenames or local URLs in your CSV instead of remote third-party URLs. - Regenerate thumbnails afterwards: Install the official Regenerate Thumbnails plugin and temporarily disable automatic thumbnail generation during bulk imports.
3. Increase PHP max_execution_time and memory_limit
If you have access to your hosting control panel (cPanel, Plesk, or Cloudways), increase your PHP resource allocations for the duration of the import.
# Recommended php.ini or .user.ini values for bulk WooCommerce imports max_execution_time = 300 memory_limit = 512M max_input_vars = 3000 post_max_size = 64M upload_max_filesize = 64M
If using Apache, you can add these directives to your .htaccess file:
php_value max_execution_time 300 php_value memory_limit 512M
Note: On managed hosts with strict Nginx reverse proxies, changing max_execution_time may not extend the proxy gateway timeout (fastcgi_read_timeout). Safe batching (≤ 500 records) remains essential.
4. Command line import (WP-CLI) for enterprise catalogs
For catalogs with 20,000 to 50,000 products, web browser imports can be fragile due to intermittent network drops or tab suspension. Running the import through WP-CLI runs PHP directly in the terminal without HTTP gateway timeouts:
wp wc product import /path/to/catalog-part-01.csv --user=admin
WP-CLI uses the same WooCommerce core import logic as the web dashboard, but bypasses web server timeouts entirely.
Still failing?
- Cloudflare Error 524: If your store uses Cloudflare, Cloudflare drops connections after 100 seconds by default. Either gray-cloud (bypass) your domain temporarily or use safe 500-record batches.
- Variations not appearing: If records import but child variations detach, see our guide on WooCommerce variations not showing or linking.
- Duplicate SKU errors: Review our guide on "Invalid or duplicated SKU" causes & fixes.
Related: Full CatalogDock Documentation · Safe import batches (≤ 500 records) · Variations troubleshooting