Request from Django to djangorestframework from the same Docker Container timeouts

I have 2 containers with docker compose:

services:
  web:
    container_name: web
    build:
    context: .
    dockerfile: Dockerfile
    command: bash -c "python manage.py makemigrations && python manage.py migrate && python 
                      manage.py collectstatic --no-input && gunicorn mysite.wsgi:application 
                      --bind 0.0.0.0:8000"
    volumes:
       - .:/app
       - static:/app/static
     env_file:
     - .env
     ports:
      - "8000:8000"
 nginx:
    build: ./nginx
    volumes:
       - static:/app/static
    ports:
       - "80:80"
    depends_on: 
       - web

here is the nginx config:

upstream django {
  server web:8000;
}

server {
  listen 80;

location / {
    proxy_pass http://django;
    proxy_set_header X-Forwarded-Proto $scheme;
}

location /static/ {
    alias /app/static/;
}

# Increase client max body size to 50M
client_max_body_size 50M;

}

In the web container I am running django app where is also djangorestframework. If I try the API endpoints with postman it works fine. Problem is when from Django view I try call the API endpoint it timeouts. Any idea what is wrong? Thank you for you time.

Вернуться на верх