Avoiding Timeout When Exporting Large WordPress Sites

When exporting large WordPress sites with thousands of posts and comments, I occasionally run into an issue where the WordPress export tool times out before it’s finished building the XML export file. This can usually be remedied by updating the config files for Apache and PHP. Temporarily increasing the amount of time allowed for a single request should solve the problem. Note that you’ll need access to your server’s config files to make these changes. If you don’t have access, explain to your web host what you’re trying to do and they should be able to help you out.

Assuming you have access, here are some values that you can try:

In the Apache config file, try setting Timeout 300, which means that a single request is allowed to take up to 300 seconds to process before it’s shut down.

You’ll have to make a similar change in the PHP config file. That line will look like max_execution_time = 300. While you’re in there, you may also want to increase the maximum amount of memory available to PHP for a single request. memory_limit = 256M should do the trick.

After you’ve made your config updates, restart Apache so that they take effect. Now you should be able to export your site without any problems. Be patient, as it can take several minutes to export a large site. The values above will give you up to 5 minutes. If it takes longer than that, the process will continue to timeout and you’ll have to make the values even larger.

It’s important to note that after you’re done with the export you should change the settings back to their initial values. No ordinary request should take 300 seconds. Leaving the timeout values that high will allow poorly written scripts to tie up Apache processes for a long time, which will seriously impact your server’s performance.