File upload fails with “request timedout after 30 seconds”

When you’re trying to upload large files (usually over 50Mb), your server can throw the following fatal error: request timeout after X seconds where X is a number, usually between 30 and 90.

Why does this “timedout” error appear?

All servers have a maximum execution time. That’s the maximum time code may run on your server. This is implemented to combat server/resource abuse. By default, this maximum execution time is often set to 30 seconds (3000ms).

The error appears when your server takes longer than the maximum execution time to respond or complete a task. Large files need a lot of time to upload to your server, so it is natural this may exceed the configured time limit and throw this error.

Fix the error

The error can be fixed by increasing the maximum allowed execution time. This can be done in a couple of ways. We’ll discuss 2 ways:

  1. The easy way: via a plugin
  2. The harder (but preferred) way: by changing the wp-config.php file.

If you’re also using our modern ajax uploader (by enabling it via WooCommerce → Settings → Product Fields), you have to add an additional code snippet to increase the execution time.

1. Fixing the “timedout” error via a WordPress plugin

Install the Increase Maximum Upload File Size | Increase Execution Time WordPress plugin to your site. Go to Media > Increase Upload Limit and enter a higher number in the Maximum Execution Time box. You can set it to something like 300, 600, or 900. Once you’re done, click Save Changes.

2. Fixing the “timedout” error via code

The following approach requires a bit more work on your end but is favorable as it does not require an additional plugin.

Browse to your WordPress code files on your web host via FTP or SFTP. Find and open the root folder (usually named after your site or something like public, public html or html) and find the wp-config.php file.

Clicking on the file either opens it for editing, or downloads it to your computer. Edit the file and add the following line of code at the bottom:


Once that is done, save (or re-upload) the file back via FTP.

Increase execution time of the ajax (modern) uploader

If you’re using our modern ajax uploader, as enabled in the settings via WooCommerce → Settings → Product Fields, you will also need to add the code snippet below to your site to increase the execution time on the front-end of your website.

Supply your license key to unlock the code

Since this is a custom-coded snippet, please enter your license key so we can verify your purchase.

Read here how to add the code snippet to your website.

Was this article helpful?

Related Articles