Fixing WordPress Importer Timeouts, Memory Errors, and Upload Limits
Content
Many users encounter issues when trying to import large XML files into WordPress using the WordPress Importer plugin. Common problems include fatal memory errors, HTTP timeouts (408, 500, or 413 errors), upload size limits, and incomplete imports. These are not necessarily bugs in the plugin itself but are often related to server configuration limits. This guide will explain why these errors occur and provide the most effective solutions to overcome them.
Why Do These Errors Happen?
The WordPress Importer plugin performs a resource-intensive process. It must parse a large XML file, create database entries for every post, page, and comment, and often download and process numerous media files. This requires significant amounts of server memory (RAM), CPU processing time, and temporary disk space. If your server's PHP configuration or web server settings have low limits for any of these resources, the import process will fail.
Common Solutions and Workarounds
1. Increase PHP Memory and Execution Limits
The most common errors are "Fatal error: Out of memory" or "Allowed memory size exhausted." This means the import process needs more RAM than your server currently allows. To fix this, you need to increase your PHP limits. The key settings to modify in your php.ini file are:
memory_limit = 256M max_execution_time = 300 max_input_time = 300 upload_max_filesize = 64M post_max_size = 64M
Important: After changing these values, you must restart your web server (e.g., Apache or Nginx) for the changes to take effect. If you don't have access to php.ini, you can try adding these lines to your WordPress wp-config.php file:
define('WP_MEMORY_LIMIT', '256M');
set_time_limit(300);
2. Compress Your XML File
If you cannot increase your upload_max_filesize, a clever workaround is to compress your XML file. The importer can process .gz (gzip) compressed files. A 20MB XML file might compress down to a 2MB .gz file, allowing you to upload it within a lower size limit.
How to do it: If you have 7-Zip (Windows) or gzip (Linux/Mac) installed, simply compress your XML file. Right-click the file, select compress, and ensure the output is a .gz file. Then, upload the compressed file through the importer.
3. Split a Large XML File into Smaller Chunks
For very large imports (over 50MB), even with high server limits, the process can time out. The most reliable solution is to split your WordPress export (WXR) file into smaller pieces. You can use free online tools or desktop applications called "WXR File Splitters" to do this. Import the smaller files one by one. This approach is highly recommended for imports containing thousands of posts or media items.
4. Check Your Server's /tmp Directory
During import, especially with many media files, the plugin uses the server's /tmp directory for temporary storage. If this directory runs out of space, media imports will fail with "Zero size file downloaded" errors. If you have server access, check the available space in /tmp. Freeing up space or configuring your system to use a different temporary directory with more space can resolve this.
5. Verify the XML File Integrity
Sometimes, an export file can become corrupted, leading to errors like "Premature end of data in tag." If you see these errors, try re-exporting your content from the source website. Ensure the export process completes fully without interruption.
Summary of Key Configuration Directives
| Setting | What it Does | Recommended Value |
|---|---|---|
memory_limit |
Maximum RAM a script can use | 256M or higher |
max_execution_time |
Maximum time a script can run (seconds) | 300 |
upload_max_filesize |
Maximum size of a single uploaded file | 64M or higher |
post_max_size |
Maximum size of total POST data | Must be larger than upload_max_filesize |
If you continue to experience issues, please check with your web hosting provider, as they may enforce hard limits on these values that cannot be changed in your own php.ini file.
Related Support Threads Support
-
error during import of users for large XML filehttps://wordpress.org/support/topic/error-during-import-of-users-for-large-xml-file/
-
Blank site when importinghttps://wordpress.org/support/topic/blank-site-when-importing/
-
How I solved problems with Importer timeoutshttps://wordpress.org/support/topic/how-i-solved-problems-with-importer-timeouts/
-
323 KB too big, and my import won't work :(https://wordpress.org/support/topic/323-kb-too-big-and-my-import-wont-work/
-
[Plugin: WordPress Importer] Fatal error: Out of memoryhttps://wordpress.org/support/topic/plugin-wordpress-importer-fatal-error-out-of-memory/
-
Large Imports can expend /tmp directory sizehttps://wordpress.org/support/topic/large-imports-can-expend-tmp-directory-size/
-
Timing out while importing XML from WordPress.comhttps://wordpress.org/support/topic/timing-out-while-importing-xml-from-wordpresscom/
-
Import from ZIP and Restarting Importhttps://wordpress.org/support/topic/restarting-import/
-
Fatal error: Maximum execution time exceeded during theme unit test import.https://wordpress.org/support/topic/fatal-error-maximum-execution-time-exceeded-during-theme-unit-test-import/
-
Add LIBXML_PARSEHUGE parameter to LoadXML for importing contentfields over 10MBhttps://wordpress.org/support/topic/add-libxml_parsehuge-parameter-to-loadxml-for-importing-contentfields-over-10mb/
-
keeps timing outhttps://wordpress.org/support/topic/keeps-timing-out-4/
-
Error Uploadinghttps://wordpress.org/support/topic/error-uploading-3/
-
Large imports break up…https://wordpress.org/support/topic/large-imports-break-up/
-
Jetpack?https://wordpress.org/support/topic/jetpack-59/
-
change maximum sizehttps://wordpress.org/support/topic/change-maximum-size/
-
[IMPORTANT] About large WRX file importshttps://wordpress.org/support/topic/important-about-large-wrx-file-imports/
-
Import Issueshttps://wordpress.org/support/topic/import-issues-14/
-
Cant Import 37 Mb Filehttps://wordpress.org/support/topic/cant-import-37-mb-file/
-
Problem with local importhttps://wordpress.org/support/topic/problem-with-local-import/
-
Feature request: please add a task in wp-cron to process imported fileshttps://wordpress.org/support/topic/feature-request-please-add-a-task-in-wp-cron-to-process-imported-files/
-
Importer Fails – Uploaded file Exceeds upload_max_filesize – but it doesn’thttps://wordpress.org/support/topic/importer-fails-uploaded-file-exceeds-upload_max_filesize-but-it-doesnt/
-
500 Error Timeouthttps://wordpress.org/support/topic/500-error-timeout-2/
-
[Plugin: WordPress Importer] Clean install, no plugs yet – Importer not workinghttps://wordpress.org/support/topic/plugin-wordpress-importer-clean-install-no-plugs-yet-importer-not-working/
-
takes longer timehttps://wordpress.org/support/topic/takes-longer-time/
-
[Plugin: WordPress Importer] Import results in 25 different resolutions of same image-filehttps://wordpress.org/support/topic/plugin-wordpress-importer-import-results-in-25-different-resolutions-of-same-image-file/
-
500 error wordpress importerhttps://wordpress.org/support/topic/500-error-wordpress-importer/
-
Changing PHP settings to get the import to not timeouthttps://wordpress.org/support/topic/changing-php-settings-to-get-the-import-to-not-timeout/
-
maximal upload file sizehttps://wordpress.org/support/topic/maximal-upload-file-size/
-
Not enough memory allocatedhttps://wordpress.org/support/topic/not-enough-memory-allocated/
-
how to import the bigger xml file?https://wordpress.org/support/topic/how-to-import-the-bigger-xml-file/
-
Error importhttps://wordpress.org/support/topic/error-import-5/
-
upload limits php.inihttps://wordpress.org/support/topic/upload-limits-phpini/
-
trouble with 4.0 importerhttps://wordpress.org/support/topic/trouble-with-40-importer/
-
Still returning 413 status codehttps://wordpress.org/support/topic/importer-still-returns-413-status/
-
Plugin do not import all of postshttps://wordpress.org/support/topic/plugin-do-not-import-all-of-posts/
-
408 Request Timeout – HELP!https://wordpress.org/support/topic/408-request-timeout-help/
-
Cannot Import my Blog contenthttps://wordpress.org/support/topic/cannot-import-my-blog-content/
-
Premature end of data in taghttps://wordpress.org/support/topic/premature-end-of-data-in-tag/
-
Why max upload only 2MB on other wp instalation work 8mb manhttps://wordpress.org/support/topic/why-max-upload-only-2mb-on-other-wp-instalation-work-8mb-man/