1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

Nginx, 504 Gateway Time-out

Discussion in 'Plesk 11.x for Linux' started by OllyStubbs, Oct 8, 2012.

  1. OllyStubbs

    OllyStubbs New Pleskian

    10
    35%
    Joined:
    Aug 10, 2012
    Messages:
    5
    Likes Received:
    0
    Hi guys,

    I am getting the above error on a page that takes longer than 60 seconds to complete, and it throws the 504 gateway time-out error, bang on 60 seconds.

    Where can I increase the timeout value in nginx?

    Also, when I try to disable nginx, it defaults the virtual host for the sites to /var/www/vhosts/default/htdocs.

    Any idea's greatly appreciated.

    Regards,
     
  2. IgorG

    IgorG Forums Analyst Staff Member

    49
    24%
    Joined:
    Oct 27, 2009
    Messages:
    24,543
    Likes Received:
    1,240
    Location:
    Novosibirsk, Russia
    Possible reason of error 504 - executable script does not fit in the allotted time limit. This happens when the script calls to other sites, or just doing a serious operation, for example, is building a search index.
    As possible solution you can increase the value PHP max_execution_time or facilitate script.
     
  3. OllyStubbs

    OllyStubbs New Pleskian

    10
    35%
    Joined:
    Aug 10, 2012
    Messages:
    5
    Likes Received:
    0
    Thanks for your reply, That's already set to 600 seconds,

    I forgot to paste the error that is written to the log /var/log/nginx/error.log
    2012/10/08 23:47:34 [error] 17090#0: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: <My IP>, server: , request: "GET /sync/sync_tables_dump.php HTTP/1.1", upstream: "http://127.0.0.1:7080/sync/sync_tables_dump.php", host: "domain"

    Hope you can help.
     
  4. GiorgosI

    GiorgosI Basic Pleskian

    21
    73%
    Joined:
    Nov 6, 2009
    Messages:
    64
    Likes Received:
    3
    I have exactly the same error.
    I googled it and I always come up with four parameters of nginx, which affect fastcgi sites too, and need to be altered.
    They are:
    client_header_timeout, client_body_timeout, send_timeout and fastcgi_read_timeout.

    I cannot find those parameters in /etc/nginx/nginx.conf.
    Where should I add/alter those parameters?
     
  5. IgorG

    IgorG Forums Analyst Staff Member

    49
    24%
    Joined:
    Oct 27, 2009
    Messages:
    24,543
    Likes Received:
    1,240
    Location:
    Novosibirsk, Russia
    In the 'server' section if config.
     
  6. Neosurfer01

    Neosurfer01 New Pleskian

    10
     
    Joined:
    Oct 15, 2012
    Messages:
    2
    Likes Received:
    0
    Hi,

    same problem here.

    Where do i have to enter these values?

    In the ngnix.conf looks like this:


    /etc/ngnix/ngnix.conf
    Best regards
     
  7. Neosurfer01

    Neosurfer01 New Pleskian

    10
     
    Joined:
    Oct 15, 2012
    Messages:
    2
    Likes Received:
    0
  8. GiorgosI

    GiorgosI Basic Pleskian

    21
    73%
    Joined:
    Nov 6, 2009
    Messages:
    64
    Likes Received:
    3
    This article is right if you want to put them in the configuration of each virtual host.

    I have easier solution which has the same result.
    I read nginx documentation and it says that those parameters can be set in the 'http' section of config too.

    Also, in the 'http' section of /etc/nginx/nginx.conf there is the line:
    So, you may just create a .conf file in the /etc/nginx/conf.d/ folder with the desired values of those parameters.
    Restart nginx and they will be applied to all virtual hosts.
     
  9. GravuTrad

    GravuTrad Regular Pleskian

    28
    23%
    Joined:
    Apr 28, 2006
    Messages:
    269
    Likes Received:
    0
    A resume of the solution could it be possible please?

    I have this sometimes (strange cause nginx is activated but not used, i use apache instead, but i have this bug.)
     
  10. GravuTrad

    GravuTrad Regular Pleskian

    28
    23%
    Joined:
    Apr 28, 2006
    Messages:
    269
    Likes Received:
    0
    Same problem

    And this is not normal. same report.

    errors finded:
    and i found this:

    http://www.tekovic.com/fixing-timeout-between-nginx-and-php-fpm

    even if php-fpm is not installed by default...
     
    Last edited: Jun 19, 2013
  11. noname1

    noname1 New Pleskian

    10
    85%
    Joined:
    Nov 3, 2012
    Messages:
    18
    Likes Received:
    0
    i have big problem - Nginx, 504 Gateway Time-out - plesk 11.5.30 - and i cant to sent any newsletter .
    please do ti something immiadiately

    upgrade from 11.0.9 to 11.5.30

    here some log for /var/log/nginx/error.log


    *21522 upstream timed out (110: Connection timed out) while reading response header from upstream, client: localhost, server: domain.com, request: "POST /administrator/index.php?tmpl=component&option=com_acymailing HTTP/1.1", upstream: "localhost:7080/administrator/index.php?tmpl=component&option=com_acymailing", host: "domain.com", referrer: "http://localhost/administrator/index.php?option=com_acymailing&ctrl=queue&task=process&tmpl=component&mailid=0"
     
    Last edited: Jul 2, 2013
  12. GiorgosI

    GiorgosI Basic Pleskian

    21
    73%
    Joined:
    Nov 6, 2009
    Messages:
    64
    Likes Received:
    3
    Have you tried the solutions provided above?
    Edit your /etc/nginx/nginx.conf and alter those parameters in the 'http' section (set timeouts according to your needs):
    send_timeout 120;
    proxy_read_timeout 120;
    proxy_connect_timeout 120;

    If they are not there you may add them or create a .conf file in /etc/nginx/conf.d/ folder with those values.
    Then restart nginx:
    # /etc/init.d/nginx restart
     
  13. noname1

    noname1 New Pleskian

    10
    85%
    Joined:
    Nov 3, 2012
    Messages:
    18
    Likes Received:
    0
    hello giorgos i will try - thank you for the clarification
    ;-)
     
  14. MisterU

    MisterU Program manager Staff Member

    14
     
    Joined:
    Jun 17, 2013
    Messages:
    91
    Likes Received:
    4
    noname1,

    You could setup php max_execution_time setting in Plesk (subscription level). Plesk automagically set the same value for nginx and fastcgi corresponding timeouts so you don't need additional actions with configuration files.
     
  15. noname1

    noname1 New Pleskian

    10
    85%
    Joined:
    Nov 3, 2012
    Messages:
    18
    Likes Received:
    0
    hello SergeyUgdyzhekov - thank you for response - can you tell the right time to add here - for example the time 3600 it is correct ?
    also the max_input_time i put it here the same time ?

     
  16. PriyanA

    PriyanA Regular Pleskian

    17
    35%
    Joined:
    Apr 25, 2012
    Messages:
    178
    Likes Received:
    9
    Location:
    Melbourne, Australia
    SergeyUgdyzhekov Could you please double check on,

    "You could setup php max_execution_time setting in Plesk (subscription level). Plesk automagically set the same value for nginx and fastcgi corresponding timeouts so you don't need additional actions with configuration files. "

    set "max_execution_time" in subscription level.

    But doesn't seems to work.

    First fcgi 45 sec, if i increase it manually via conf file, then nginx Bad gateway after 60 sec.

    Could you please advise on this?

    Plesk 11.0.9 | CentOS 6.4
     
    Last edited: Aug 15, 2013
  17. MisterU

    MisterU Program manager Staff Member

    14
     
    Joined:
    Jun 17, 2013
    Messages:
    91
    Likes Received:
    4
    PiryanA,

    My explanation related to PP11.5
     
  18. PriyanA

    PriyanA Regular Pleskian

    17
    35%
    Joined:
    Apr 25, 2012
    Messages:
    178
    Likes Received:
    9
    Location:
    Melbourne, Australia
    Thank you very much for your reply SergeyUgdyzhekov

    PP11.0.9 | CentOS 6.4

    Set max_execution_time 600 ---> | Service Plan > Edit Service Plan > PHP Settings

    Set FcgidIOTimeout 600 | /etc/httpd/conf.d/fcgid.conf

    What is the recommended and best way to Set Nginx, 504 Gateway Time-out?

    Regards,
    PriyanA
     
  19. MisterU

    MisterU Program manager Staff Member

    14
     
    Joined:
    Jun 17, 2013
    Messages:
    91
    Likes Received:
    4
    PriyanA,

    Sure you need set 'proxy_read_timeout' in nginx conf too
     
  20. PriyanA

    PriyanA Regular Pleskian

    17
    35%
    Joined:
    Apr 25, 2012
    Messages:
    178
    Likes Received:
    9
    Location:
    Melbourne, Australia
    Hi,

    But i cant seem to find this "proxy_read_timeout"

    All i have is the code below in /etc/nginx/nginx.conf

    Code:
    #user  nginx;
    worker_processes  1;
    
    #error_log  /var/log/nginx/error.log;
    #error_log  /var/log/nginx/error.log  notice;
    #error_log  /var/log/nginx/error.log  info;
    
    #pid        /var/run/nginx.pid;
    
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
        #                  '$status $body_bytes_sent "$http_referer" '
        #                  '"$http_user_agent" "$http_x_forwarded_for"';
    
        #access_log  /var/log/nginx/access.log  main;
    
        sendfile        on;
        #tcp_nopush     on;
    
        #keepalive_timeout  0;
        keepalive_timeout  65;
        #tcp_nodelay        on;
    
        #gzip  on;
        #gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    
        server_tokens off;
    
        include /etc/nginx/conf.d/*.conf;
    }
    
    am i looking in the right place?

    Thank you
     
Loading...