Docker-compose postgresql problem

Hi there i have a docker-compose setup that successfully starts up
It is a simple web app the has a post endpoint to which i am sending a file
When i send the file with curl from the host that runs docker compose
curl -F "file=@myfile.txt" http://localhost/v1/uploadfile
On the web app container “mw” I receive the following errors

When i initialize the database from the web app and create the tables, it connects and succeeds.
There is established communication between them.
Following is the composer file

version: "3.8"
services:
  nginx:
    image: nginx-mw 
    ports: [80:80]
    volumes: 
     - /etc/nginx
    environment:
     - "NGINX_PORT=80"
  mw:
    image: mw-new
    ports: [8080:8080]
    environment:
     - "FLASK_HOST=0.0.0.0"
     - "FLASK_PORT=8080"
     - "DB_HOST=postgresql"
    deploy: 
      mode: replicated
      replicas: 1
  postgresql:
    image: psql-mw 
    ports: [5432:5432]
    #   volumes: 
    # - /etc/postgresql
    # - /var/log/postgresql
    # - /var/lib/postgresql
    deploy: 
      mode: replicated
      replicas: 1
        #networks:
        #  mw-network:
        #    driver: overlay
  rabbitmq:
    image: rabbitmq:3.6
    ports: [5672:5672]
    environment: 
     - "RABBITMQ_DEFAULT_PASS=pass"
     - "RABBITMQ_DEFAULT_USER=user"
     - "RABBITMQ_DEFAULT_VHOST=host"

The second time i’ve runned docker-compose up everything started working.
Thank you !