Upstream timed out (110: Connection timed out) while reading response header from upstream

Today I was investigating a weir derror I found on the server logs:

Upstream timed out (110: Connection timed out) while reading response header from upstream

This nginx timeout error was located in a nginx – apache proxy server, where nginx is serving all static content and apache all the dynamic.

Investigating the error and after trying a few fixs, I found this error can happen in two scenarios:

1) Nginx as Proxy, like the one happened to me.

Try adding proxy_read_timeout option into your virtual host configuration, it should look like this:

proxy_read_timeout 150;

Place it inside your root location config:

location / {
        ...
        proxy_read_timeout 150;
        ...
    }

2) Nginx as standalone server with php-fpm or another upstream application.

If this is your case, try adding fastcgi_read_timeout option:

fastcgi_read_timeout 150;

With your php-fpm configuration it should look like this:

location ~* .php$ {
    include         fastcgi_params;
    fastcgi_index   index.php;
    fastcgi_read_timeout 150;
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
}

On both cases, just restart nginx to apply the changes.

Note: some scripts may need to increase/decrease the “150″ value I posted here.

Popular search terms:

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>