Errors

Error: Plesk 504 Gateway Time-out nginx

In this article, we have explained how to resolve Plesk 504 Gateway Time-out nginx error.

An operation or a script that takes more than 60 seconds to complete fails on a website hosted in Plesk: nginx 504 Gateway Time-out

An operation or a script that takes more than 60 seconds to complete fails on a website with:

nginx 504 Gateway Time-out

The following error message appears on domain’s Logs page or in domain’s nginx error logfile /var/www/vhosts/system/example.com/logs/proxy_error_log file:

[error] 1096#0: *25 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 203.0.113.2, server: example.com, request: “GET / HTTP/1.1”, upstream: “fastcgi://unix:///var/www/vhosts/system/example.com/php-fpm.sock”, host: “example.com” 

The operation fails for the script/part of the site which is expected to run more than 60 seconds.

Solution

For all domain

1. Connect to the Plesk server via SSH.
2. Create a backup of the /etc/nginx/nginx.conf file:

# cp -p /etc/nginx/nginx.conf /etc/nginx/nginx.conf.back

3. Open the /etc/nginx/nginx.conf file in a text editor. In this example, wу are using the vi editor:

# vi /etc/nginx/nginx.conf

4. Add the following directives at the end of the ‘http’ section to increase the timeout limit to 180 seconds (3 minutes):

http {
<…>
include /etc/nginx/conf.d/.conf;

proxy_send_timeout 180s;
proxy_read_timeout 180s;
fastcgi_send_timeout 180s;
fastcgi_read_timeout 180s;
}

Save the changes and close the file.
Restart the nginx service:

# service nginx restart

Retry the failed operation on the website. If it fails again, you can hire our Support Engineers  to fix the issue quickly.

For one domain

1. In Plesk, go to Domains > example.com > Apache & nginx Settings.
2. Scroll down to Additional nginx directives and add the following lines to the Additional nginx directives field to increase the timeout limit to 180 seconds (3 minutes):

proxy_connect_timeout 180s;
proxy_send_timeout 180s;
proxy_read_timeout 180s;
fastcgi_send_timeout 180s;
fastcgi_read_timeout 180s

3. Apply the changes.
4. Retry the failed operation on the website. If it fails again, you can hire our Support Engineers  to fix the issue quickly.

[Need assistance to fix this error or install tools? We’ll help you.]

Related Articles