Welcome! Log In Create A New Profile

Advanced

How to resolve 504 Gateway Time-out Error

How to resolve 504 Gateway Time-out Error
December 10, 2020 12:29PM
I'm running a Django web application upon Gunicorn and Nginx, on a Ubuntu 16 server. The application times-out even for a slighter load and goes to 504 Gateway Timeout page. I've made several changes to my nginx.conf file, by increasing the proxy timeout duration and I've tried I've increasing the gunicorn timeout duration and keep alive duration. Nothing seems to be working to resolve this issue. Also, the webserver doesn't even recover from the timeout, and I've restart the service to run the application again. This issue has been going since long, and I've been looking everywhere to resolve this, which sort of become a big headache for me. Request all to please help me resolve this.

nginx.conf:

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 900s;
proxy_connect_timeout 900s;
proxy_read_timeout 900s;
proxy_send_timeout 900s;
send_timeout 900s;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# SSL Settings
##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

upstream app_server {
server 0.0.0.0:8000 fail_timeout=0;
}

server {
listen 80 default_server;
return 444;
}

server {
listen 80;
client_max_body_size 4G;
server_name 10.10.10.10;

location /static {
alias /home/rootadmin/WeatherIntelligence/static;
}

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_pass http://app_server;
proxy_redirect off;
}
}

}

Gunicorn conf:
[program:WIA]
directory=/home/WIA/WIA
command=/home/WIA/WIA/venv/bin/gunicorn --log-level=debug --workers=5 --worker-class=gthread --threads=5 --bind 0.0.0.0:8000 WeatherCloud.wsgi:application
user=rootadmin
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
stderr_logfile=/home/WIA/WIA/WIA.err.log
stdout_logfile=/home/WIA/WIA/WIA.out.log
Re: How to resolve 504 Gateway Time-out Error
December 11, 2020 03:20AM
Hello All,

Request anyone to please respond and help me resolve this issue.

Thanks in advance.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 132
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready