Skip to content

Scan stops working after a fixed period of time / 504 error?

Make sure you have added the new Background Tasker cron job in your web panel cron tab settings. Read this topic to find how to setup tasker cron job. As it will fix scan halt and background processing automatically for you.
If you have added it successfully and still background process getting disconnected and halts then follow below additional adjustments:

This issue is very common if you are using nginx proxy, apache with php-fpm/fastcgi and have lower timeout value settings on php script run time when you scan thousand of emails list. Based on server configuration this issue can be resolved in several ways.

If you’re using VPS hosting, there are a few extra things you can try to fix the 504 gateway timeout error. They would involve tweaking the server settings and increasing specific resource limits.

Apache #

Apache users may increase the default timeout value in the httpd.conf file. For example:

# Timeout: The number of seconds before receives and sends time out.
Timeout 99999

Furthermore, increasing the max_execution_time limit in php.ini can also bring positive results:

max_execution_time = 99999;

Save the changes, restart apache, and re-check. The 504 gateway timeout error should be gone if the cause was insufficient request timeout value.

Nginx + FastCGI (php-fpm enabled): #

If your VPS utilizes Nginx, try increasing the following values in /etc/nginx/conf.d/timeout.conf

proxy_connect_timeout 99999; 
proxy_send_timeout 99999; 
proxy_read_timeout 99999; 
send_timeout 99999;

In php.ini set :

max_execution_time = 99999;

Change request_terminate_timeout parameter (commented by default) in /etc/php-fpm.d/www.conf (for Debian /etc/php5/fpm/pool.d/www.conf) file:

request_terminate_timeout = 99999;

Add fastcgi_read_timeout variable inside the ‘nginx’ virtual host configuration:

fastcgi_read_timeout 99999;

Add/increase the following values in the ‘http’ section of the /etc/nginx/nginx.conf file:

fastcgi_buffers 8 128k;
fastcgi_buffer_size 256k;

Restart both ‘apache’ and ‘nginx’.

==========================================

If above steps doesn’t work, try this one..

  1. Open your nginx.conf file located in /etc/nginx directory.
  2. Add this below piece of code under http { section:
    client_header_timeout 99999;
    client_body_timeout 99999;
    fastcgi_read_timeout 99999;
    client_max_body_size 32m;
    fastcgi_buffers 8 128k;
    fastcgi_buffer_size 128k;
    

    Note: If its already present, change the values according.

  3. Reload Nginx and php5-fpm.
    $ service nginx reload
    $ service php5-fpm reload
    

    If the error persists, consider increasing the values.

=========================================

Changes in php.ini

Try raising max_execution_time setting in php.ini file (CentOS path is /etc/php.ini):

max_execution_time = 99999;

Changes in PHP-FPM Try raising request_terminate_timeout setting in php.ini file (CentOS path is /etc/php-fpm.d):


request_terminate_timeout = 99999;
Changes in Nginx Config

Finally, add fastcgi_read_timeout variable inside our Nginx virtual host configuration:

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

Reload PHP-FPM and Nginx

service php–fpm restart
service nginx restart