How to increase page timeout to prevent 504 error?

rajankaneria picture rajankaneria · Feb 3, 2012 · Viewed 15.5k times · Source

I am running a file with considerable amount of code and have to process it for 1000 users. It takes approximately 55 seconds to process 500 users, so I have to increase the default gateway timeout time.

From this question, I found that I have to increase fastcgi_read_timeout, but I don't know where to put it in fastcgi.conf.

Answer

Sergei Lomakov picture Sergei Lomakov · Feb 3, 2012

fastcgi_read_timeout should be put into a location which you're using for processing requests to your file.

location {
     fastcgi_pass you.app:9000;
     ... 
     fastcgi_read_timeout 900s; # 15 minutes
}

Please, see more examples in documentation