2

I get a 499 error after 60s whatever the config I try. I use Docker on a 8 core/32GB server and there is another nginx/lets-encrypt reverse proxy in front for the others containers. I am more on the dev side of the craft. I suppose I need to run my batch in background and I am going to explore that if I can't fix this, but I need to understand this error.

gunicorn worker seems to run after the error :

[2019-06-01 17:49:31 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2019-06-01 17:49:31 +0000] [1] [INFO] Using worker: threads
[2019-06-01 17:49:31 +0000] [9] [INFO] Booting worker with pid: 9
[2019-06-01 17:49:31 +0000] [10] [INFO] Booting worker with pid: 10
[2019-06-01 17:49:31 +0000] [11] [INFO] Booting worker with pid: 11
[2019-06-01 17:49:31 +0000] [12] [INFO] Booting worker with pid: 12
[2019-06-01 17:49:31 +0000] [13] [INFO] Booting worker with pid: 13
[2019-06-01 17:49:31 +0000] [14] [INFO] Booting worker with pid: 14
[2019-06-01 17:49:31 +0000] [15] [INFO] Booting worker with pid: 15
[2019-06-01 17:49:31 +0000] [16] [INFO] Booting worker with pid: 16

nginx version: nginx/1.15.12

gunicorn 19.9.0

Django 2.2.1

conf nginx

upstream cobalt {
  server cobalt:8000;
}

# Catch all requests with an invalid HOST header
server {
    server_name "";
    listen      8000;
    return      444;
}

# portal
server {
    listen 8000;
    server_name xxxxxxxx;

    location / {
        proxy_set_header Host $host;
        proxy_pass http://cobalt;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Connection "";
        proxy_connect_timeout 1200s;
        proxy_read_timeout 1200s;
        proxy_send_timeout 1200s;
        client_max_body_size 100M;
        client_body_buffer_size 100M;
        client_body_timeout 1200s;
        keepalive_timeout 1200s;
        send_timeout 1200s;
        uwsgi_read_timeout 1200s;
    }

    location /static/ {
        autoindex on;
        alias /static/;
    }

    location /private-x-accel-redirect/ {
        internal;
        alias   /media/;
    }

}

conf gunicorn

"""gunicorn WSGI server configuration."""
bind = '0.0.0.0:8000'
timeout = 1200
workers = 8
threads = 2
asktyagi
  • 2,860
  • 2
  • 8
  • 25
Patrick Aymar
  • 21
  • 1
  • 2
  • 1
    499 means client disconnected. You can’t fix it with you timeout settings. Provably you should change your software to return something. If it’s really time consuming thing consider to return job id and have some means to check results using this id – Alexey Ten Jun 02 '19 at 10:43
  • Check out this https://stackoverflow.com/questions/12973304/nginx-499-error-codes hope this will help. – asktyagi Jun 02 '19 at 11:38
  • I already check that post, I am aware of "client closed the connection " but I don't thing my client (django) closed the connection but just don't throw anything to nginx, it's why I tried to get nginx wait a bit longer, I tried every timout settings, I thing, but after 60s I get the 499 stuff. It's why I ask the question here, the webDev answer would be " Why the hell your app is not responding to a client request under 60s !". I know the solution is some celery/redis stuff but after 2 days on this 60s/499 I want to find the solution. – Patrick Aymar Jun 02 '19 at 15:50
  • If Django is your client, you should configure timeouts on django's side. – Alexey Ten Jun 03 '19 at 07:17
  • Sorry I dont' get you, what's the django's timeout you are talking about ?, Django continue during several minutes and finish is task after the 60s/499 of nginx, fortunatly nginx don't kill the gunicorn workers after 60s. The " client closed the connection " seems dubious at best in my case, I'm pretty sure django doesn't do that, maybe gunicorn but why. – Patrick Aymar Jun 04 '19 at 15:16
  • @PatrickAymar in that case I guess that django is a server and you client is a browser. – Alexey Ten Jun 05 '19 at 00:45
  • @AlexeyTen, yes difficult to know who is the client for a go-between, I think both but then "client closed the connection" is ambiguous or maybe it's more an issue with my knowledge of english langage ... I will try that, thanks. – Patrick Aymar Jun 05 '19 at 17:00

1 Answers1

0

did you solve this problem? I'm with the same problem and I don't have any idea what is causing this 499 error. I cofigurated my server and everthing the same way you did.

EDIT 1: Hey guys, I discovered the source of this problem in MY CASE. For some reason saving info in session: django.session['value1'] = 'value2' This's causing the error, I removed the django.session to test and everything has works great. I dont discover the solution yet, but as soon as I solve this problem I'll update in here.

EDIT 2: I solved the problem, in my case de data base from AWS RDS couldn't be access because I made some shit. I recreated the database and now everything is working great.

Kurame
  • 1
  • 1
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://serverfault.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://serverfault.com/help/whats-reputation), you can also [add a bounty](https://serverfault.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/555048) – Quantim Jun 28 '23 at 06:27