upstream timed out

Discussion in 'Site & Server Administration' started by Ruriko, Sep 3, 2011.

  1. #1
    I have nginx as my web server with latest php 5.3.8. I run a scrapper script and I get this error

    2011/09/03 07:39:36 [error] 1449#0: *1 upstream timed out (110: Connection timed out) while reading upstream, client: 58.174.129.205, server: [url]www.deliciousmanga.com[/url], request: "GET /wpm-crn/scp/?tkn=uVXcaozY70AfJgbVGy0z HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.deliciousmanga.com", referrer: "http://www.deliciousmanga.com/wp-admin/admin.php?page=wp-manga/mng/scp/mgr"
    Code (markup):
    To fix this error I had to add

    fastcgi_connect_timeout 60; 
    fastcgi_send_timeout 180; 
    fastcgi_read_timeout 180;
    Code (markup):
    But when I do add these options it causes the site not responding all it does is load forever and in the end it would just say Bad gateway 504. The vps is running fine but it's just the site doesn't respond/load.

    this is my nginx config

    server {
        server_name www.deliciousmanga.com deliciousmanga.com;
        access_log /srv/www/deliciousmanga.com/logs/access.log;
        error_log /srv/www/deliciousmanga.com/logs/error.log;
        root /srv/www/deliciousmanga.com/public_html;
    
        location / {
            index index.html index.htm index.php;
        }
    
            location ~ \.php$ {
                    include fastcgi_params;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    fastcgi_intercept_errors on;
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
            }
    
    if (!-e $request_filename) {
      rewrite ^.*$ /index.php last;
    }
    
    fastcgi_connect_timeout 60; 
    fastcgi_send_timeout 180; 
    fastcgi_read_timeout 180; 
    } 
    
    PHP:
     
    Ruriko, Sep 3, 2011 IP
  2. AnthonyG

    AnthonyG Well-Known Member

    Messages:
    114
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    135
    #2
    Add it to your nginx.conf file in the http section:

    
    
    http {
            fastcgi_buffers                 512 4k;
            fastcgi_buffer_size             1m;
            fastcgi_connect_timeout         30;
            fastcgi_send_timeout            30;
            fastcgi_read_timeout            30;
            fastcgi_busy_buffers_size       1m;
            fastcgi_temp_file_write_size    1m;
            fastcgi_intercept_errors        on;
    }
    Code (markup):
    There is no reason to set it above 30, unless you have a poorly coded script or you need to repair tables via pma.

    If the above dont help, change it back to a port:
    
    server {
        server_name www.deliciousmanga.com deliciousmanga.com;
        access_log /srv/www/deliciousmanga.com/logs/access.log off;
        error_log /srv/www/deliciousmanga.com/logs/error.log notice;
        root /srv/www/deliciousmanga.com/public_html;
    
        location / {
            index index.html index.htm index.php;
        }
    
             location ~ .php$ {
                      include fastcgi_params;
                      fastcgi_pass 127.0.0.1:9000;
                      fastcgi_index index.php;
                      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            }
    
    }
    
    Code (markup):
    I assume your using the php-fpm manager?

    You also need to change the listen in php-fpm.conf to the port.
     
    Last edited: Sep 5, 2011
    AnthonyG, Sep 5, 2011 IP