Cannot reach service in docker container despite port mapping with docker-compose

I have these files to start a webserver inside a docker container. I can see the service running in the container at port 8000, but I cannot access it via the web browser.

Dockerfile

FROM continuumio/miniconda3
ENV PYTHONUNBUFFERED=1
RUN mkdir /static
SHELL ["/bin/bash", "-c"]
RUN apt update && apt install -y build-essential time libgraphviz-dev graphviz
RUN conda create -n env -c conda-forge python==3.10 django==4 pip #&& conda init bash
COPY backend/requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY ./backend /backend
WORKDIR /backend/

docker-compose file

version: "3.3"
   
services:
  backend:
    container_name: backend
    restart: always
    user: ${UID}
    build: 
      context: .
      dockerfile: dockerfiles/Dockerfile-backend
    env_file:
        - ./.env
    command: ./manage.py runserver
    volumes:
      - ./backend/:/backend/
      - ${STATIC}:/static/
    ports:
      - "127.0.0.1:8000:8000"
    depends_on:
      - db
  
  db:
    container_name: db
    restart: always
    image: postgres:13.4
    volumes:
      - ${DB}:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres

I am running docker on an Ubuntu 20.04 VM and I have a port forwarding to that VM. I used commands like docker network prune before, so I am not sure, whether I deleted a requirement also by using Network Monitoring tools. I also tried stopping the container and running docker container prune and docker-compose up, but it does not work as it should.

curl localhost:8000
>>> curl: (56) Recv failure: Connection reset by peer

If you don’t get a solution here, I’d suggest asking this question on stackoverflow or some other forum that was more Docker-oriented.

I don’t really understand the graphviz connection here either. I think you’d have better luck asking some docker people for help.