nginx 504 error: Gateway Timeout

Refers to:

  • Plesk 12.5 for Linux
  • Plesk Onyx for Linux
  • Plesk 11.0 for Linux
  • Plesk 11.5 for Linux
  • Plesk 12.0 for Linux


2016-11-16 12:40:16 UTC


2017-02-27 18:36:40 UTC


Was this article helpful?

Have more questions?

Submit a request

nginx 504 error: Gateway Timeout


Multiple '504 errors' are shown on SSL pages or it takes a lot of time to load the website page. This can be fixed by restarting the 'apache' service, but the problem reoccurs.

Also the issue accrues when any large file (1+ GB) is being uploaded to any php software.

In domain logs /var/www/vhosts/ the following error can be found:

2013/11/15 03:32:13 [error] 12699#0: *5042589 upstream timed out (110: Connection timed out) while reading response header from upstream, client:, server:, request: "GET /wp-login.php HTTP/1.0", upstream: "", host: "", referrer: ""


Timeout error is often caused by issues on the backend connection that is serving the content. To fix this, first, you have to figure out what configuration you are using.


For Nginx as Proxy (php-fpm disabled)

  • To apply settings globally, increase the timeout values by creating the file /etc/nginx/conf.d/timeout.conf and restarting 'nginx' service:

    # cat /etc/nginx/conf.d/timeout.conf

    proxy_connect_timeout       600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
  • To increase timeout settings for a particular domain, add the lines mentioned above to 'Additional Nginx directives' at:

    Plesk > Subscriptions > > Websites & Domains > > Apache & nginx Settings

For Nginx + FastCGI (php-fpm enabled)

  • Increase the value of max_execution_time directive (by choosing the value from the drop-down menu or by setting it manually) at:

    Plesk > Subscriptions > > Websites & Domains > > PHP Settings

  • Add fastcgi_read_timeout 300; directive inside the 'nginx' virtual host configuration at:

    Plesk > Subscriptions > > Websites & Domains > > Apache & nginx Settings > Additional Nginx directives

  • Add/increase the following values in the 'http' section in the /etc/nginx/nginx.conf file:

    fastcgi_buffers 8 128k;
    fastcgi_buffer_size 256k;

    Restart 'php-fpm', 'apache' and 'nginx' services.

Note: Setting value for max_execution_time parameter in PHP settings of a domain in Domains > > PHP Settings will set the same value for FcgidIOTimeout parameter in virtual host configuration.

Have more questions? Submit a request
Please sign in to leave a comment.