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_timeoutandproxy_read_timeoutdefault 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:

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:

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

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 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
- 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).
- 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 shows such an update pass in detail.
- 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, raiseproxy_read_timeout. Keep PHP’smax_execution_timeat least as high. On shared hosting, ask the host; on Cloudflare’s standard plans the 100-second limit cannot be raised. - 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.
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
- WordPress Import Stuck at X%? Why It Stops and How to Finish It
- Export a Large WordPress Site (100,000 Posts) Without Timeouts
Get the free plugin on WordPress.org.

Comments 0
Have a question or a tip to share? Leave it below.