I've read other posts on this and have implemented the best answers and am still having this error.
I'm running a Django app using Nginx and supervisor (and daphne due to Django Channels).
I get a 504 Gateway Time-out when I go to my domain name.
I have read the output of the nginx error logs:
2019/02/26 19:34:52 [error] 22668#22668: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: xx.xx.xxx.14, server: myapp.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "www.myapp.com"
I've tried adding time out settings:
 # time out settings
        proxy_connect_timeout 159s;
        proxy_send_timeout   600;
        proxy_read_timeout   600;
        proxy_buffer_size    64k;
        proxy_buffers     16 32k;
        proxy_busy_buffers_size 64k;
        proxy_temp_file_write_size 64k;
        proxy_pass_header Set-Cookie;
        proxy_redirect     off;
        proxy_hide_header  Vary;
        proxy_set_header   Accept-Encoding '';
I've tried adding
        proxy_http_version 1.1;
        proxy_set_header Connection "";
adding a file (/etc/nginx/conf.d/timeout.conf) with
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
Nothing seems to work. I'm a beginner so if I am missing something here let me know!
configuration file /etc/nginx/sites-enabled/myapp
upstream myapp {
    server 127.0.0.1:8000;
}
server {
    server_name myapp.com www.myapp.com;
    location = /favicon.ico { access_log off; log_not_found off; }
    location / {
        try_files $uri @proxy_to_app;
    }
    location /static/ {
        root /home/me/myapp/src/myapp;
    }
    location /media/  {
        root /home/me/myapp/src/myapp;
        include /etc/nginx/mime.types;
    }
    location @proxy_to_app {
        proxy_pass http://myapp;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;
    }
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/myapp.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/myapp.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
    if ($host = www.myapp.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    if ($host = myapp.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    listen 80;
    server_name myapp.com www.myapp.com;
    return 404; # managed by Certbot
 
    