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 performing 2 steps.

1. Increase server execution time

The error can be fixed by increasing the maximum allowed upload time on the server side. This can be done in a couple of ways:

Via your host

You can ask your hosting provider to increase the “maximum execution time” on your site to 900 seconds. Often, their support team is happy to do this for you at no extra cost!

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 600 or 900. Once you’re done, click Save Changes.

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:

set_time_limit(900);

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

2. Increase allowed upload time of the modern uploader

If you’re using our modern 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 allowed upload 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