An operation or a script that takes more than 60 seconds to complete fails on a website hosted in Plesk: nginx 504 Gateway Time-out




  • Avatar

    now is 502 error, plesk have started again

  • Avatar
    Pavel Mikhaylov (Edited )

    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:

  • Avatar

    Yes i do but 504 error all 21 domains

  • Avatar
    Bulat Tsydenov

    @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.

  • Avatar


    if you experience problems after modifying nginx.conf add the line proxy_connect_timeout 1200s;

    it could be useful ;)

  • Avatar
    Ivan Postnikov

    @yoyoy, yes, this is mentioned in step 1 of resolution.

  • Avatar

    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. 

  • Avatar
    Ivan Postnikov

    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.

  • Avatar

    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.


  • Avatar
    Jerome Nameche

    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 

  • Avatar
    Alisa Kasyanova

    @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 to investigate the issue in more details.

  • Avatar
    Jack Lee

    I get this exact error.


    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.  

  • Avatar
    Dinara Aspembitova (Edited )
    Hello @Jack Lee,
    You can use strace to check the issue
    For example, in the following way:
    strace -ff -s 400  <comamnd to run php script> 2>&1 | tee strace111.log
    When "the display ceases to be updated", stop the command and check created strace111.log file.
    Alternatively, you can create a ticket  as described here 
  • Avatar
    Jef Far

    Don't forget to restart both Apache and Nginx!

  • Avatar
    Alisa Kasyanova

    @Jeff Hanes
    When you press OK in Apache & nginx Settings, both Apache and nginx are restarted

  • Avatar
    Jan Bludau

    solved the problem server wide :-)

  • Avatar
    Felix Schulze

    @Jan Bludau How did you solve that server wide?

  • Avatar
    Denis Bykov

    @Felix Schulze

    I assume that using the second part of resolution, by editing /etc/nginx/nginx.conf file.

Please sign in to leave a comment.

Have more questions? Submit a request