• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Nginx, 504 Gateway Time-out

OllyStubbs

New Pleskian
Hi guys,

I am getting the above error on a page that takes longer than 60 seconds to complete, and it throws the 504 gateway time-out error, bang on 60 seconds.

Where can I increase the timeout value in nginx?

Also, when I try to disable nginx, it defaults the virtual host for the sites to /var/www/vhosts/default/htdocs.

Any idea's greatly appreciated.

Regards,
 
Possible reason of error 504 - executable script does not fit in the allotted time limit. This happens when the script calls to other sites, or just doing a serious operation, for example, is building a search index.
As possible solution you can increase the value PHP max_execution_time or facilitate script.
 
Thanks for your reply, That's already set to 600 seconds,

I forgot to paste the error that is written to the log /var/log/nginx/error.log
2012/10/08 23:47:34 [error] 17090#0: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: <My IP>, server: , request: "GET /sync/sync_tables_dump.php HTTP/1.1", upstream: "http://127.0.0.1:7080/sync/sync_tables_dump.php", host: "domain"

Hope you can help.
 
I have exactly the same error.
I googled it and I always come up with four parameters of nginx, which affect fastcgi sites too, and need to be altered.
They are:
client_header_timeout, client_body_timeout, send_timeout and fastcgi_read_timeout.

I cannot find those parameters in /etc/nginx/nginx.conf.
Where should I add/alter those parameters?
 
I have exactly the same error.
I googled it and I always come up with four parameters of nginx, which affect fastcgi sites too, and need to be altered.
They are:
client_header_timeout, client_body_timeout, send_timeout and fastcgi_read_timeout.

I cannot find those parameters in /etc/nginx/nginx.conf.
Where should I add/alter those parameters?

In the 'server' section if config.
 
Hi,

same problem here.

Where do i have to enter these values?

In the ngnix.conf looks like this:


/etc/ngnix/ngnix.conf
#user nginx;
worker_processes 1;

#error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;

#pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;
#tcp_nodelay on;

#gzip on;
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";

server_tokens off;

include /etc/nginx/conf.d/*.conf;
}

Best regards
 
This article is right if you want to put them in the configuration of each virtual host.

I have easier solution which has the same result.
I read nginx documentation and it says that those parameters can be set in the 'http' section of config too.

Also, in the 'http' section of /etc/nginx/nginx.conf there is the line:
include /etc/nginx/conf.d/*.conf;
So, you may just create a .conf file in the /etc/nginx/conf.d/ folder with the desired values of those parameters.
Restart nginx and they will be applied to all virtual hosts.
 
A resume of the solution could it be possible please?

I have this sometimes (strange cause nginx is activated but not used, i use apache instead, but i have this bug.)
 
I am getting the above error on a page that takes longer than 60 seconds to complete, and it throws the 504 gateway time-out error, bang on 60 seconds.
Same problem

Also, when I try to disable nginx, it defaults the virtual host for the sites to /var/www/vhosts/default/htdocs.

And this is not normal. same report.

errors finded:
upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: , request: "POST /plesk-billing/mbapi/remote.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/sw-engine.sock", host: "localhost:8443"
FastCGI sent in stderr: "PHP message: PHP Warning: psasem_rinit(): failed to open semaphore file: /usr/local/psa/var/psasem.sem: Permission denied in Unknown on line 0" while reading response header from upstream, client: 127.0.0.1, server: , request: "PUT /sp/bb8dg3prjdg3c8hczqt2kqftxe5s1b5011o/fi/wzgilq14b1ebwigdmqhzgd6v2e5s1bajqqz/target_sp/kw4j5g287u0d3fzowmgbr9p8e5s1b7xsz6/accounts/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:19001", host: "127.0.0.1:8443"

and i found this:

http://www.tekovic.com/fixing-timeout-between-nginx-and-php-fpm

even if php-fpm is not installed by default...
 
Last edited:
i have big problem - Nginx, 504 Gateway Time-out - plesk 11.5.30 - and i cant to sent any newsletter .
please do ti something immiadiately

upgrade from 11.0.9 to 11.5.30

here some log for /var/log/nginx/error.log


*21522 upstream timed out (110: Connection timed out) while reading response header from upstream, client: localhost, server: domain.com, request: "POST /administrator/index.php?tmpl=component&option=com_acymailing HTTP/1.1", upstream: "localhost:7080/administrator/index.php?tmpl=component&option=com_acymailing", host: "domain.com", referrer: "http://localhost/administrator/index.php?option=com_acymailing&ctrl=queue&task=process&tmpl=component&mailid=0"
 
Last edited:
Have you tried the solutions provided above?
Edit your /etc/nginx/nginx.conf and alter those parameters in the 'http' section (set timeouts according to your needs):
send_timeout 120;
proxy_read_timeout 120;
proxy_connect_timeout 120;

If they are not there you may add them or create a .conf file in /etc/nginx/conf.d/ folder with those values.
Then restart nginx:
# /etc/init.d/nginx restart
 
noname1,

You could setup php max_execution_time setting in Plesk (subscription level). Plesk automagically set the same value for nginx and fastcgi corresponding timeouts so you don't need additional actions with configuration files.
 
hello SergeyUgdyzhekov - thank you for response - can you tell the right time to add here - for example the time 3600 it is correct ?
also the max_input_time i put it here the same time ?

noname1,

You could setup php max_execution_time setting in Plesk (subscription level). Plesk automagically set the same value for nginx and fastcgi corresponding timeouts so you don't need additional actions with configuration files.
 
SergeyUgdyzhekov Could you please double check on,

"You could setup php max_execution_time setting in Plesk (subscription level). Plesk automagically set the same value for nginx and fastcgi corresponding timeouts so you don't need additional actions with configuration files. "

set "max_execution_time" in subscription level.

But doesn't seems to work.

First fcgi 45 sec, if i increase it manually via conf file, then nginx Bad gateway after 60 sec.

Could you please advise on this?

Plesk 11.0.9 | CentOS 6.4
 
Last edited:
Thank you very much for your reply SergeyUgdyzhekov

PP11.0.9 | CentOS 6.4

Set max_execution_time 600 ---> | Service Plan > Edit Service Plan > PHP Settings

Set FcgidIOTimeout 600 | /etc/httpd/conf.d/fcgid.conf

What is the recommended and best way to Set Nginx, 504 Gateway Time-out?

Regards,
PriyanA
 
Hi,

But i cant seem to find this "proxy_read_timeout"

All i have is the code below in /etc/nginx/nginx.conf

Code:
#user  nginx;
worker_processes  1;

#error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

#pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    #tcp_nodelay        on;

    #gzip  on;
    #gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    server_tokens off;

    include /etc/nginx/conf.d/*.conf;
}

am i looking in the right place?

Thank you
 
Back
Top