Applicable to:
- Plesk for Linux
Symptoms
-
Unable to access a PHP script on a website such as https://example.com/app/script.php with 504 Gateway Time-out error showing up in the browser
-
The following error shows up in the nginx error log
/var/www/vhosts/system/example.com/logs/proxy_error_log
for the website:[error] 4853#0: *21 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 203.0.113.2, server: example.com, request: "GET /app/script.php HTTP/2.0", upstream: "https://203.0.113.3:7081/app/updateprice.php", hos t: "example.com"
-
Increasing the time out values as explained here does not help
-
If you place a diagnostic phpinfo.php file in the main directory of the website and try to open it, it loads right away
Cause
The PHP script loads that should be loaded is either loading infinitely (or above 15 minutes) or not exiting properly and causes an infinite loading loop. This usually happens when using a poorly or incorrectly written PHP script.
Resolution
Contact the PHP app or website developer in order to have the script code reviewed and optimized.
-
Connect to the server via SSH
-
Run the following command to execute PHP script behalf subscriber's user:
# time sudo -H -u jdoe bash -c "/opt/plesk/php/8.0/bin/php /var/www/vhosts/example.com/httpdocs/app/script.php"
Note: Change the PHP version, Subscription system user and exact script path as necessary.
-
Check the last lines of the output, would be something like:
real 15m11.605s
user 0m0.117s
sys 0m0.224s
Note: In the example above case, the script ran for more than 15 minutes, which is a clear sign that it has been written poorly.
Comments
0 comments
Please sign in to leave a comment.