How to disable LiteSpeed connection timeouts
What is LiteSpeed and why are there connection timeouts?
LiteSpeed is the webserver we use on all our hosting servers instead of Apache.
We set a LiteSpeed connection timeout to ensure users with potential scripting issues do not cause long-running processes on our servers. This helps to ensure that users don’t end up with processes stacking up and hitting account limits for the number of processes. However, in some cases you may need to disable this limit while fixing a coding issue or if you simply have a process on the website that exceeds the LiteSpeed timeout.
You can lift the limit for a specific script that legitimately needs to run for a long time. To do this you need a .htaccess file in the same folder as the website itself - in most cases public_html - and the following code must go at the very top of that file, above any other rules. Rewrite rules are position-sensitive, so on a WordPress site this needs to sit above the # BEGIN WordPress block rather than below it.
<IfModule Litespeed>
RewriteEngine On
RewriteRule (wp-cron|backupbuddy|importbuddy)\.php - [E=noabort:1, E=noconntimeout:1]
</IfModule>
Replace wp-cron|backupbuddy|importbuddy with the name of the script you need to protect - those three are simply the usual WordPress culprits. Separate several script names with |, and keep the \.php on the end.
Please don't apply this to every request. It is tempting to use .* so it covers the whole site, and LiteSpeed specifically advise against it: on CloudLinux - which is what our shared servers run - a site that hits its resource limits while nothing is allowed to be aborted "can become completely tied up". That is the very problem this timeout exists to prevent, so a site-wide rule can cause the fault it was meant to fix. Keep the scope as narrow as you can.
Changes to .htaccess take effect straight away - there is nothing to restart. Give it a few minutes before deciding it hasn't worked, though, and if the timeout is still being applied after that, check the rule for typos rather than waiting longer. Do bear in mind that this is not the only limit: PHP has its own max_execution_time, which you can change in the PHP selector, and there is also a server-side maximum process time that we set and you cannot override. That one is one hour, and it is usually what stops a very long job - so no matter what you set in the PHP selector, a script cannot run for more than an hour. If you have something that legitimately needs longer, open a ticket and talk to us rather than widening the rule above; a job that size is usually better run as a scheduled task in smaller pieces.
Note: a .htaccess file in public_html applies to everything underneath it, including any add-on domains whose document root sits inside that folder. So a matching script name anywhere below public_html will pick this rule up too. If you only want it to affect one site, put the .htaccess file in that site's own document root instead.
We have a guide on using the cPanel File Manager to access and edit your .htaccess file.