504 Gateway Time-out in ISPmanager: site timeouts

A 504 Gateway Time-out means the script runs longer than the web server is ready to wait. Usually it is a product import, an export, a plugin backup or a heavy report. The Apache log may show Timeout waiting for output from CGI script.

Timeouts must be raised in the config of the site itself — in its VirtualHost and server blocks. Global server settings do not help: every site has its own virtual host with its own values.

Raise three limits to the same value, for example 3600 seconds: Apache, Nginx and PHP.

1. Open the site config

  1. Log in to ISPmanager as root. "Sites" → select the site → "Configuration files".
"Configuration files" button
"Configuration files" button

2. Apache: Timeout in the VirtualHost

  1. In the "Apache configuration file", inside <VirtualHost 127.0.0.1:8080>, add the line Timeout 3600 — for example after ServerAdmin.
<VirtualHost 127.0.0.1:8080>
	ServerName mydemo-site.com
	...
	Timeout 3600
	...
</VirtualHost>
Timeout 3600 in the site VirtualHost
Timeout 3600 in the site VirtualHost

3. Nginx: timeouts in location @fallback

  1. In the "Nginx configuration file" find the location @fallback block and add four lines to it. The block appears twice — for HTTP and for HTTPS. Add to both.
location @fallback {
	...
	proxy_connect_timeout 3600;
	proxy_send_timeout 3600;
	proxy_read_timeout 3600;
	send_timeout 3600;
}
Timeouts in location @fallback
Timeouts in location @fallback
  1. Click "Save". The panel checks the syntax and reloads the web servers.

The site runs on PHP-FPM without Apache — there is no @fallback block. Then add fastcgi_read_timeout 3600; to the location @php block and leave Apache alone.

4. PHP: execution time

Set the same max_execution_time and max_input_time for the site PHP version: the administrator — "PHP" → version → "Extended settings" (PHP settings), the user — in the PHP settings of their site (max_execution_time).

Checking

apache2ctl -t && nginx -t

Both commands must answer Syntax OK / test is successful. Run the long operation again.

The panel keeps edits made in "Configuration files". But if you change the site PHP mode or recreate the site, the config is rebuilt from the template — check the timeouts after such changes.

Restarting the web server

"Navigation board" → "Services" → select nginx or apache2 → "Restart the selected service".

Services: restart
Services: restart
Questions and answers
Three parts wait: PHP, Nginx and Apache. Raise the timeouts in the site config: Timeout in the VirtualHost and proxy timeouts in location @fallback.
Every site has its own virtual host with its own values. Global settings do not override them.
When the PHP mode changes or the site is recreated, the panel rebuilds the config. Check the timeouts after such changes.
How long the operation really takes plus a margin. For imports usually 600–3600 seconds. Very long operations are better run via Cron.