I am getting 504 timeouts message from nginx when my PHP script is running longer than usual. set_time_limit(0)
does not seem to prevent that! Does it not work
The correct answer is increasing fastcgi_read_timeout in your Nginx configuration.
Simple as that!
I solve this trouble with config APACHE ! All methods (in this topic) is incorrect for me... Then I try chanche apache config:
Timeout 3600
Then my script worked!
sudo nano /etc/nginx/nginx.conf
Add these variables to nginx.conf file:
http {
# .....
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
}
And then restart:
service nginx reload
There are three kinds of timeouts which can occur in such a case. It can be seen that each answer is focused on only one aspect of these possibilities. So, I thought to write it down so someone visiting here in future does not need to randomly check each answer and get success without knowing which worked.
So the fixes for each issue are as follows.
$.ajax({
url: "test.html",
error: function(){
// will fire when timeout is reached
},
success: function(){
//do something
},
timeout: 3000 // sets timeout to 3 seconds
});
nginx Client timeout
http{
#in seconds
fastcgi_read_timeout 600;
client_header_timeout 600;
client_body_timeout 600;
}
nginx proxied server timeout
http{
#Time to wait for the replying server
proxy_read_timeout 600s;
}
So use the one that you need. Maybe in some cases, you need all these configurations. I needed.