Django app in docker with gunicorn gives "Error handling request (no URI read)"
I'm running a django application using gunicorn inside a docker container, but I'm encountering an error on request. The application fails with the following error log:
[2024-11-13 18:50:11 +0000] [9] [ERROR] Error handling request (no URI read)
Traceback (most recent call last):
File "/usr/local/lib/python3.13/site-packages/gunicorn/workers/sync.py", line 133, in handle
req = next(parser)
...
SystemExit: 1
But the request is eventually processed and a response is provided, but it takes a time.
Here is mt dockerfile:
FROM python:3.13.0-alpine3.20
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /app
RUN apk update && \
apk add --no-cache jq python3-dev build-base gcc jpeg-dev zlib-dev libpq-dev
COPY Pipfile.lock .
RUN jq -r '.default | to_entries[] | .key + .value.version ' Pipfile.lock > requirements.txt && \
pip install -r requirements.txt
COPY . .
ENTRYPOINT ["sh", "./entrypoint.sh"]
Here is my docker-compose.yml:
services:
app:
build: .
container_name: app
volumes:
- .:/app
- ./src/media:/app/src/media
ports:
- "8000:8000"
depends_on:
- db
env_file:
- .env
restart: always
db:
image: postgres:17.0-alpine3.20
container_name: postgres_db
volumes:
- postgres_data:/var/lib/postgresql/data
env_file:
- .env
restart: always
volumes:
postgres_data:
I'm starting gunicorn with this command:
gunicorn config.wsgi:application --bind 0.0.0.0:8000
How to solve this problem? Thanks!