django-DefectDojo icon indicating copy to clipboard operation
django-DefectDojo copied to clipboard

UWSGI container crashes when logging in

Open enidevops opened this issue 10 months ago • 3 comments

Bug description I did a fresh install of DefectDojo on a k3s cluster using the latest DefectDojo Helm chart and DefectDojo v2.54.1. The installation/sync completes without errors, and the UI loads, but login fails consistently.

When submitting the login form (POST /login?next=/), the browser shows a 502 Bad Gateway (see screenshot). At the same time, the uwsgi container crashes/restarts without any errors in the logfile, and the nginx container logs show upstream failures to the uWSGI socket.

Image

Uwsgi logs:

uwsgi.log

Nginx logs:

2026/01/19 14:50:46 [error] 15#15: *18666 upstream prematurely closed connection while reading response header from upstream, client: 10.244.1.123, server: , request: "POST /login?next=/ HTTP/1.1", upstream: "uwsgi://unix:///run/defectdojo/uwsgi.sock:", host: "portal.tail073687.ts.net", referrer: "https://portal.tail073687.ts.net/login?next=/" 10.244.1.123 - - [19/Jan/2026:14:50:46 +0000] "POST /login?next=/ HTTP/1.1" 502 497 "https://portal.tail073687.ts.net/login?next=/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36" "100.65.7.94" 2026/01/19 14:50:46 [error] 15#15: *18666 connect() to unix:///run/defectdojo/uwsgi.sock failed (111: Connection refused) while connecting to upstream, client: 10.244.1.123, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:///run/defectdojo/uwsgi.sock:", host: "portal.tail073687.ts.net", referrer: "https://portal.tail073687.ts.net/login?next=/" 10.244.1.123 - - [19/Jan/2026:14:50:46 +0000] "GET /favicon.ico HTTP/1.1" 502 497 "https://portal.tail073687.ts.net/login?next=/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36" "100.65.7.94" 2026/01/19 14:50:51 [error] 13#13: *18686 connect() to unix:///run/defectdojo/uwsgi.sock failed (111: Connection refused) while connecting to upstream, client: 10.244.1.1, server: , request: "GET /uwsgi_health HTTP/1.1", upstream: "uwsgi://unix:///run/defectdojo/uwsgi.sock:", host: "portal.tail073687.ts.net" 10.244.1.1 - - [19/Jan/2026:14:50:51 +0000] "GET /uwsgi_health HTTP/1.1" 502 497 "-" "kube-probe/1.34" "-"

Here are the logs from the postgresql pod (I tried an external db as well, same result):

"dojo_system_settings"."non_common_password_required", "dojo_system_settings"."api_expose_error_details", "dojo_system_settings"."filter_string_matching" FROM "dojo_system_settings" LIMIT 21 2026-01-18 21:38:21.282 GMT [159] LOG: checkpoint starting: time 2026-01-18 21:40:11.005 GMT [159] LOG: checkpoint complete: wrote 1090 buffers (6.7%); 0 WAL file(s) added, 0 removed, 0 recycled; write=109.225 s, sync=0.402 s, total=109.723 s; sync files=1624, longest=0.051 s, average=0.001 s; distance=9372 kB, estimate=9372 kB; lsn=0/22304F0, redo lsn=0/2230460 2026-01-19 04:03:28.091 GMT [159] LOG: checkpoint starting: time 2026-01-19 04:03:28.402 GMT [159] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.302 s, sync=0.003 s, total=0.312 s; sync files=3, longest=0.002 s, average=0.001 s; distance=6 kB, estimate=8435 kB; lsn=0/2231EF0, redo lsn=0/2231E98

Additionally, here is my values.yaml:

values.txt

Steps to reproduce Steps to reproduce the behavior:

  1. Go to defectdojo.url
  2. Put in Login Credentials
  3. Click on 'Login'
  4. See error

Expected behavior Container doesn't crash and the login succeeds

Deployment method (select with an X)

  • [ ] Docker Compose
  • [ X] Kubernetes
  • [ ] GoDojo

Environment information

  • Operating System: Ubuntu 24.04 + k3s
  • DefectDojo + Helm 2.54.1

enidevops avatar Jan 19 '26 15:01 enidevops

At first glance this looks like a deployment issue where some pods are unabled to reach other pods. You may get a larger audience via our slack channel: https://github.com/DefectDojo/django-DefectDojo?tab=readme-ov-file#community-getting-involved-and-updates

valentijnscholten avatar Jan 19 '26 18:01 valentijnscholten

@valentijnscholten I'm not sure what the exact issue is, but using the setting:

django:  
  uwsgi:
    appSettings:
      processes: 2
      threads: 2

fixed it

enidevops avatar Jan 20 '26 13:01 enidevops

Same for me. But the right explanation is memory limit that is too low. I face this kind of message in kernel: Memory cgroup out of memory: Killed process 20525 (uwsgi)

To fix that I just increase the memory limits:

django:
  uwsgi:
    appSettings:
      processes: 4
      threads: 4
    resources:
      limits:
        memory: "2Gi"
        cpu: "1000m"
      requests:
        memory: "512Mi"
        cpu: "500m"

jsreynaud avatar Feb 16 '26 18:02 jsreynaud