How to Fix “upstream timed out (110: Connection timed out) while reading response header from upstream” in NGINX

Problem :

I noticed there are the errors in NGINX when trying to update my WordPress post. In my case, NGINX service running as web service with php-fpm behind varnish proxy :

[root@vps ~]# tail -f /var/log/nginx/ehowstuff.com.error.log
2014/12/14 15:33:15 [error] 1040#0: *52134 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1

Solution :

This is how i resolved my issue. I have added the following lines to /etc/nginx/nginx.conf

location ~ .php$ {
..
..
    fastcgi_send_timeout 150s;
    fastcgi_read_timeout 150s;
..
..
}

Then restart nginx service :

/etc/init.d/nginx restart

or

service nginx restart