Tim
Tim
RRailway
Created by Tim on 2/5/2024 in #✋|help
Django with Gunicorn gives frequent [CRITICAL] WORKER TIMEOUTs on simple requests
I have been trying to deploy an app (no real users on this deploy yet). The deployment works, but some site requests that barely require any amount of back-end processing time (i.e. retrieve 1 model in the django admin without any calculated fields) will lead to Gunicorn timeouts. After a few seconds it will often work again, keep working for a while, and eventually go back to timeout's. Suggestions are very much appreciated. I have 2 gunicorn workers and 2 replica's and I am the only user.
[2024-02-05 12:21:37 +0000] [16] [CRITICAL] WORKER TIMEOUT (pid:27)
[2024-02-05 12:21:38 +0000] [16] [ERROR] Worker (pid:27) exited with code 1
[2024-02-05 12:21:38 +0000] [16] [ERROR] Worker (pid:27) exited with code 1.
[2024-02-05 12:21:39 +0000] [16] [CRITICAL] WORKER TIMEOUT (pid:37)
[2024-02-05 12:21:39 +0000] [16] [ERROR] Worker (pid:37) exited with code 1
[2024-02-05 12:21:39 +0000] [16] [ERROR] Worker (pid:37) exited with code 1.
[2024-02-05 12:21:37 +0000] [16] [CRITICAL] WORKER TIMEOUT (pid:27)
[2024-02-05 12:21:38 +0000] [16] [ERROR] Worker (pid:27) exited with code 1
[2024-02-05 12:21:38 +0000] [16] [ERROR] Worker (pid:27) exited with code 1.
[2024-02-05 12:21:39 +0000] [16] [CRITICAL] WORKER TIMEOUT (pid:37)
[2024-02-05 12:21:39 +0000] [16] [ERROR] Worker (pid:37) exited with code 1
[2024-02-05 12:21:39 +0000] [16] [ERROR] Worker (pid:37) exited with code 1.
I am running it using docker with the following dockerfile
FROM python:3.11-slim
RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt
COPY . /app
WORKDIR /app
COPY docker_entrypoint.sh .
ENTRYPOINT ["sh", "/app/docker_entrypoint.sh"]
FROM python:3.11-slim
RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt
COPY . /app
WORKDIR /app
COPY docker_entrypoint.sh .
ENTRYPOINT ["sh", "/app/docker_entrypoint.sh"]
Where the entrypoint will do migrations and eventually run
PYTHONPATH=`pwd`/project gunicorn project.wsgi.wsgi_production:application --timeout 60 --workers 2 --access-logfile - --log-level WARNING
PYTHONPATH=`pwd`/project gunicorn project.wsgi.wsgi_production:application --timeout 60 --workers 2 --access-logfile - --log-level WARNING
25 replies
RRailway
Created by Tim on 12/17/2023 in #✋|help
Logs filled with errors due to django allowed hosts settings
My issue is similar to https://discord.com/channels/713503345364697088/1172062119710171176/1172063615537385504 My logs are filled with stuff like this:
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '35.204.95.109:8052'. You may need to add '35.204.95.109' to ALLOWED_HOSTS.
...
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '0.0.0.0:8052'. You may need to add '0.0.0.0' to ALLOWED_HOSTS.
...
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '0.0.0.0:8052'. You may need to add '0.0.0.0' to ALLOWED_HOSTS.
...
ERROR Invalid HTTP_HOST header: 'www'. You may need to add 'www' to ALLOWED_HOSTS.
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'www'. You may need to add 'www' to ALLOWED_HOSTS.
ERROR Invalid HTTP_HOST header: '35.204.95.109:8052'. You may need to add '35.204.95.109' to ALLOWED_HOSTS.
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '35.204.95.109:8052'. You may need to add '35.204.95.109' to ALLOWED_HOSTS.
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '35.204.95.109:8052'. You may need to add '35.204.95.109' to ALLOWED_HOSTS.
...
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '0.0.0.0:8052'. You may need to add '0.0.0.0' to ALLOWED_HOSTS.
...
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '0.0.0.0:8052'. You may need to add '0.0.0.0' to ALLOWED_HOSTS.
...
ERROR Invalid HTTP_HOST header: 'www'. You may need to add 'www' to ALLOWED_HOSTS.
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'www'. You may need to add 'www' to ALLOWED_HOSTS.
ERROR Invalid HTTP_HOST header: '35.204.95.109:8052'. You may need to add '35.204.95.109' to ALLOWED_HOSTS.
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '35.204.95.109:8052'. You may need to add '35.204.95.109' to ALLOWED_HOSTS.
The site works fine, but it makes monitoring actual errors rather annoying. How to fix this?
12 replies
RRailway
Created by Tim on 11/25/2023 in #✋|help
NS_ERROR_REDIRECT_LOOP
I am running a Django server using a docker file. Project id a9861a99-1c51-4b34-8970-6e92d5cd7f47 The deploy log states that the gunicorn started succesfully, but I get an infinite redirect cycle when I try to access the website? Any suggestions how to avoid this? I don't have this problem on localhost. So I am getting 301's to the same url looped.
Installed 62 object(s) from 13 fixture(s)
[2023-11-25 13:55:02 +0000] [16] [INFO] Starting gunicorn 21.2.0
[2023-11-25 13:55:02 +0000] [16] [INFO] Listening at: http://0.0.0.0:6429 (16)
[2023-11-25 13:55:02 +0000] [16] [INFO] Using worker: sync
[2023-11-25 13:55:02 +0000] [18] [INFO] Booting worker with pid: 18
Installed 62 object(s) from 13 fixture(s)
[2023-11-25 13:55:02 +0000] [16] [INFO] Starting gunicorn 21.2.0
[2023-11-25 13:55:02 +0000] [16] [INFO] Listening at: http://0.0.0.0:6429 (16)
[2023-11-25 13:55:02 +0000] [16] [INFO] Using worker: sync
[2023-11-25 13:55:02 +0000] [18] [INFO] Booting worker with pid: 18
7 replies