Error: 504 Gateway Timeout after 60 seconds.

#1
Description:
We are trying to run a PHP script that takes 300 seconds to execute.
After exactly 60 seconds, the connection is closed with an error: 504 Gateway Timeout.
However, the script continues to run in the background and finishes its task successfully after 300 seconds - the script is not being killed (that's OK!).

Issue:

Fetching the actual output from the endpoint is impossible because the connection is closed faster than it needs for execution.

What steps should be taken to increase the 60 seconds timeout limit to 300 seconds?

Actions taken (didn't work):
#1) .htaccess
RewriteEngine On
RewriteRule .* - [E=noabort:1, E=noconntimeout:1]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

#2) Manual configuration
Server Configuration > Tuning > Connection Timeout (secs) = 300

#3) Service restart
systemctl restart lsws

System:
PHP 8.0.25
LiteSpeed/1.7.16 Open (BUILD built: Mon Oct 17 21:33:28 UTC 2022)
module versions:
lsquic 3.1.1
modgzip 1.1
cache 1.64
mod_security 1.4

Best regards and I would be grateful for any suggestions
 
#4
To address the 504 Gateway Timeout issue, consider checking your server's timeout settings, PHP's `max_execution_time`, and possibly using asynchronous processing to handle long-running tasks without timing out.
 
#5
To fix the 504 error, match the server timeout and PHP max_execution_time with your script's runtime. Also, check if your load balancer is causing the timeout.
 
Top