Applicable to:
- Plesk for Linux
Symptoms
-
An operation or a script that takes more than 60 seconds to complete fails on a website with the following error in a web-browser:
PLESK_INFO: nginx 504 Gateway Time-out
-
The following error message appears on the Logs page (Domains > example.com > Logs) or in the domain's nginx error logfile
/var/www/vhosts/system/example.com/logs/proxy_error_log
:CONFIG_TEXT: [error] 1096#0: *25 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 203.0.113.2, server: example.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/example.com/php-fpm.sock", host: "example.com"
Cause
The default timeout limit is 60 seconds for proxying requests from nginx to Apache.
Resolution
If a script takes more than 60 seconds to execute, increase the timeout limit.
-
Go to Domains > example.com > Apache & nginx Settings.
-
Add the following lines to the Additional nginx directives field to increase the timeout limit to 180 seconds (3 minutes):
CONFIG_TEXT: proxy_connect_timeout 180s;
proxy_send_timeout 180s;
proxy_read_timeout 180s;
fastcgi_send_timeout 180s;
fastcgi_read_timeout 180s; -
Apply the changes.
Comments
23 comments
now is 502 error, plesk have started again
Hello iamkingsleyf,
Do you experience the issue with 502 error at the moment?
If you do, please let us know, what are other symptoms of the issue? What is in the subscription log files?
I would also like to recommend contacting our support: https://www.plesk.com/contact-support
Yes i do but 504 error all 21 domains
@iamkingsleyf, the assistance with this issue was provided to you in scope of support ticket. If you need further assistance, please reply to the ticket.
hello
if you experience problems after modifying nginx.conf add the line proxy_connect_timeout 1200s;
it could be useful ;)
@yoyoy, yes, this is mentioned in step 1 of resolution.
I would also suggest limiting search time period so you're not searching logs months or years old:
grep -R "upstream timed out" /var/www/vhosts/*/logs/ | grep "2018/10/3*" | wc -l &
For example.
Hello @Glenn,
Thank you for the hint, this command modification may be useful for other Pleskians.
However, the command in symptom does not require modification in accordance with the present date and is more universal.
Hi Ivan,
When I ran the command without a date limit, the result was 12000+ and according to my tech, was parsing logs more than a year old. It's was an insanely high number.
When we ran it with date limit I got a more reasonable and realistic number of approx. 1100 and adjusted fcgi to 1200s.
Thanks for feedback.
Hi Guys,
I did the following on my Plesk. and it really helps me to make heavier request on my woocommerce webshop syncing several products with sub-webshops.
Still, I have a big issue:
Despite these lines of code in my php-settings. I can still get 504 get away error and when I have it. my server is then down for 5 long minutes ! I then try to load simply the homepage and it's white charging during 1 minutes and finally displaying the lovely 504.
why the server is getting stuck like this?? how to avoid that?
I don't see any peak of CPU or memory usage during these 5 minutes.
How can I know what are the optimale timeout limits?! If I increase too much these values I also think server will crash.
thx in advance !!
I need help and knowledge here..please
@Jerome Nameche
Hi! The needed timeout values should be determined based on many parameters: the load on the server, the domain number, the code of domains etc. etc. You may try to increase the values a little bit and monitor the server: if the issue persists, increase the values again and repeat it if necessary.
As for the stuck server: it is needed to check the /var/log/messages or /var/log/syslog to find additional information about what is happening on the server, the timeout values might not be the root cause of the issue. Anyway, I recommend you to create a ticket as per https://support.plesk.com/hc/en-us/articles/213608509-How-to-submit-a-request-to-Plesk-support- to investigate the issue in more details.
I get this exact error.
Added
proxy_send_timeout 1200s;
proxy_read_timeout 1200s;
fastcgi_send_timeout 1200s;
fastcgi_read_timeout 1200s;
Changing the configuration removes the error, but NGINX still stops. By this I mean I have a PHP script outputting to the display. PHP keeps running, but after 60 seconds the display ceases to be updated. But PHP completes several minutes later.
The NGINX error log has no entry. The Server logs have no entry. The PHP log has no entry.
Don't forget to restart both Apache and Nginx!
@Jeff Hanes
When you press OK in Apache & nginx Settings, both Apache and nginx are restarted
solved the problem server wide :-)
@Jan Bludau How did you solve that server wide?
@Felix Schulze
I assume that using the second part of resolution, by editing
/etc/nginx/nginx.conf
file.Hello,
Setting these values:
doesn't change anything, always 504 after 60s. Plesk 18.0.34, PHP-FPM 7.4.18, FPM served by Nginx.
Is there any bug that don't take care about the parameters set ?
Best
Nico
Same error!
Hello Shai Dayan
It looks like you have hit a bug which is described in this KB article. This bug has already been fixed in Plesk Obsidian 18.0.40.
same error
Please sign in to leave a comment.