Proxy not working inside docker container

When I working without docker(just run React and Django in 2 sep. terminals) all works fine, but when use docker-compose, proxy not working and I got this error:

Proxy error: Could not proxy request /doc from localhost:3000 to http://127.0.0.1:8000.
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).

How to allow one image to access another through a proxy?
This my docker-compose setup:

version: "3.8"

services:
  backend:
    build: ./monkey_site
    container_name: backend
    command: python manage.py runserver 127.0.0.1:8000
    volumes:
      - ./monkey_site:/usr/src/monkey_site
    ports: 
      - "8000:8000"
    environment:
      - DEBUG=1
      - DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1
      - CELERY_BROKER=redis://redis:6379/0
      - CELERY_BACKEND=redis://redis:6379/0
    depends_on:
      - redis
    networks:
      - proj_network

  frontend:
    build: ./frontend
    container_name: frontend
    ports: 
      - "3000:3000"
    command: npm start
    volumes:
      - ./frontend:/usr/src/frontend
      - ./monkey_site/static:/usr/src/frontend/src/static    
    depends_on:
      - backend
    networks:
      - proj_network

  celery: 
    build: ./monkey_site
    command: celery -A monkey_site worker --loglevel=INFO
    volumes:
      - ./monkey_site:/usr/src/monkey_site/
    depends_on:
      - backend 
      - redis

  redis:
    image: "redis:alpine"

networks:
  proj_network:

React Dockerfile:

FROM node:18-alpine
WORKDIR /usr/src/frontend
COPY package.json .
RUN npm install
EXPOSE 3000

Django Dockerfile:

FROM python:3
ENV PYTHONUNBUFFERED=1
WORKDIR /usr/src/monkey_site
COPY requirements.txt ./
RUN pip install -r requirements.txt
1 Like

I’m facing same problem, did you got any solution?