---
title: "WordPress Import 504 Gateway Timeout: Why It Happens and How to Fix It"
url: "https://wpimportexport.com/wordpress-import-504-gateway-timeout/"
description: "Import stops with 504 Gateway Time-out? Why proxies cut long import requests and how short batches, automatic retries and WP-CLI finish the import."
type: post
published: 2026-11-29T15:00:00+00:00
modified: 2026-11-26T08:31:57+00:00
categories: ["Tutorials"]
tags: ["CSV Export"]
docs_topics: ["Bulk updates and automation"]
---

# WordPress Import 504 Gateway Timeout: Why It Happens and How to Fix It

You start a WordPress import, the progress bar moves, and then the page shows **504 Gateway Time-out** or the importer reports “Gateway Timeout” and stops. A 504 does not come from WordPress. It comes from the server in front of PHP (nginx, Apache as a proxy, a load balancer or Cloudflare), which waited for PHP to answer, gave up and returned an error page instead. PHP may still be working on your rows when that happens. This guide explains why imports hit 504s, how **Import Export by RockStarLab** avoids them and recovers from them, and what to change on the server if they keep coming.

**Free:** everything here works in the free plugin. We tested with Import Export by RockStarLab 2.2.13 and WordPress 7.1.

## Short Answer

A 504 means one request took longer than the proxy’s time limit, often 30 or 60 seconds. Import in small, time-limited requests instead of one long one: the plugin processes rows for about 20 seconds per request, saves its position after every row and continues in the next request. If a request still gets a 504, the import wizard waits and sends it again, up to six times, and the import continues from the last saved row. If 504s keep coming, lower the Batch Size, import images in a second pass, or raise the proxy’s timeout.

## Why Imports Get 504 Errors

- **One long request.** Importers that process the whole file, or large chunks of it, in one request run past the proxy limit on big files. Common limits: nginx `fastcgi_read_timeout` and `proxy_read_timeout` default to 60 seconds; Cloudflare closes the connection after 100 seconds and shows error 524; many shared hosts use 30 to 60 seconds.
- **Images in the rows.** Downloading a featured image or the images in the content can take several seconds each, so a batch of 50 posts with images can take minutes.
- **A slow or busy server.** Heavy plugins hooked into post saving (SEO, translation, search indexing) or a server under load make each row slower.
- **A short hiccup.** A restart of PHP-FPM, a deploy or a brief overload can turn one request into a 502, 503 or 504 even when the import itself is fast.

## How the Plugin Keeps Requests Short

The import runs as a series of requests. Each one handles up to **Batch Size** rows, but stops after about 20 seconds even if the batch is not finished, and does not start a row that would likely end past that time. The position is saved after every row, so the next request continues exactly where the last one stopped and no row is imported twice:

![Import Options: Batch Size 50, a batch stops early after about 20 seconds; Automatically Import Media Files checked](https://wpimportexport.com/wp-content/uploads/2026/11/import-batch-size-media-options-1024x180.webp)

_Each request stops after about 20 seconds and the next one continues._

Because of the time limit, the Batch Size rarely needs changing: a large value does not make requests longer than about 20 seconds plus one row. The rows that can still take long on their own are rows with many or very large images on a slow remote server.

## What Happens When a Request Gets a 504

To test this, we imported a CSV with 200 posts and made the server answer the second and third requests with nginx’s “504 Gateway Time-out” page. The wizard showed a note above the progress bar, waited and tried again:

![Import progress at 10 of 200 items with the note: The server did not answer in time (504 Gateway Timeout), trying again in 10 seconds, attempt 2 of 6](https://wpimportexport.com/wp-content/uploads/2026/11/import-504-retry-notice-1024x272.webp)

_After a 504 the wizard waits and sends the request again._

The fourth request went through, and the import finished with all 200 posts created, none twice:

![Import Completed Successfully: 200 successful, 200 created, 0 failed, duration 18s](https://wpimportexport.com/wp-content/uploads/2026/11/import-504-finished-200-posts-1024x464.webp)

_All 200 posts imported despite two 504 errors._

The wizard waits 5, 10, 20, 40, 60 and 60 seconds between attempts. It retries 502, 503 and 504 errors, Cloudflare’s 52x errors, 408 and 429 responses, dropped connections and HTML error pages that some hosts return instead of the plugin’s answer. Real errors from the plugin, such as a row the import cannot save, are not retried: they are shown right away.

If all six attempts fail, the wizard shows **Import Failed** and says that the import may still finish in the background. We tested that too, with every request after the first answered by a 504: the wizard gave up after the sixth attempt, and the job still finished on the server, in the background, with all 200 posts. So check the import in **Jobs** first. If it stopped there, click **Continue** once the server is responsive again to run the remaining rows. See [WordPress Import Stuck at X%? Why It Stops and How to Finish It](https://wpimportexport.com/wordpress-import-stuck-how-to-finish/) for that button and other ways to finish a stopped job.

## Import Without the Web Server: WP-CLI or an AI Agent

A 504 comes from the web server or proxy in front of PHP. With SSH access, take them out of the path: the plugin’s WP-CLI command runs the whole import in one PHP process on the server, without any HTTP request to time out.

```
wp rsl-ie import big-import.csv --type=post --user=admin
```

On our test site with Import Export by RockStarLab 2.2.63, this command imported a CSV of 2,000 posts in 12 seconds (job 6), with the same mapping by column name and the same entry in the Jobs Log as an import from the admin.

An AI agent connected through the WordPress MCP Adapter gets the same import from the plugin; WordPress itself offers it only read-only abilities for site, user and environment information. The agent uploads the file, calls `rsl-ie/import-start`, which queues the job for WP-Cron in the same short batches, and reads the progress with `rsl-ie/job-get`, so no single request runs long:

```
With Import Export by RockStarLab, import the uploaded CSV file as posts in the background and tell me when the job is done and how many rows failed.
```

## If 504s Keep Coming

1. **Lower the Batch Size** on the Options step, for example to 10, if your rows are heavy (many custom fields, page builder content, several images each).
2. **Import images in a second pass.** Turn off **Automatically Import Media Files** for the first import, then run the same file again with **Check for Existing Items by Field: Title**, **If Match Found: Update** and media import on. The first pass is fast; the second updates the same posts and downloads their images. Our guide to [importing external images into the Media Library](https://wpimportexport.com/wordpress-import-external-images-to-media-library/) shows such an update pass in detail.
3. **Raise the proxy timeout** if you manage the server. For nginx with PHP-FPM, raise `fastcgi_read_timeout` (for example to 120s) in the site’s configuration; behind another proxy, raise `proxy_read_timeout`. Keep PHP’s `max_execution_time` at least as high. On shared hosting, ask the host; on Cloudflare’s standard plans the 100-second limit cannot be raised.
4. **Use WP-CLI for very large files.** A command-line import is not behind a web proxy at all, so there is no gateway timeout. See [WP-CLI Import and Export for WordPress](https://wpimportexport.com/wp-cli-import-export-wordpress/).

## FAQ

### What does 504 Gateway Timeout mean during a WordPress import?

The web server or proxy in front of PHP waited longer than its time limit for one import request and gave up. PHP may have kept working; the error only means that request’s answer did not arrive in time.

### Will rows be imported twice after a 504?

No. The plugin saves its position after every row and a second request cannot run the same job while the first is still working, so the import continues from the last saved row.

### Should I raise the Batch Size or lower it?

For 504s, lower it if each row is heavy. A request stops after about 20 seconds anyway, so a high Batch Size does not make requests much longer, but a lower one makes the slowest request shorter.

### Does increasing max_execution_time fix 504 errors?

Not on its own. A 504 comes from the proxy’s timeout, such as nginx’s fastcgi_read_timeout or Cloudflare’s 100 seconds. PHP’s limit only matters when it is lower than the proxy’s.

## Related Guides

- [How to Import a Large CSV (100,000 Rows) into WordPress Without Crashing Your Site](https://wpimportexport.com/import-large-csv-wordpress-100k-rows/)
- [WordPress Import Stuck at X%? Why It Stops and How to Finish It](https://wpimportexport.com/wordpress-import-stuck-how-to-finish/)
- [Export a Large WordPress Site (100,000 Posts) Without Timeouts](https://wpimportexport.com/export-large-wordpress-site-without-timeouts/)

Get the free plugin on [WordPress.org](https://wordpress.org/plugins/import-export-by-rockstarlab/).
