psycopg2.OperationalError: could not connect to server: Connection refused Is the server running on host "localhost" : <p>Got Error while doing docker-compose up.</p>

<pre><code>conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5433?
could not connect to server: Cannot assign requested address
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5433?
</code></pre>

<p>docker-compose.yml:-</p>

<pre><code>version: '3'

services:
  dcs_web:
    build: .
    depends_on:
      - db
    ports:
      - "5000:5000"
  db:
    image: postgres:latest
    volumes:
      - db-data:/var/lib/postgresql/data
    ports:
      - "5433:5433"
    environment:
      - 'POSTGRES_DB:dcmDB'
      - 'POSTGRES_USER:postgres'
      - 'POSTGRES_PASSWORD:admin'

volumes:
  db-data:
</code></pre>

<p>In App config.ini:</p>

<pre><code>[DEFAULT]
DB_NAME = user
DB_PASSWORD = admin
DB_USER = postgres
DB_HOST = localhost
DB_PORT = 5433
DEBUG = True
</code></pre>

<p>I have gone throught '/var/lib/postgresql/data' location 'listen adress = *' is there . Dont know how to deal with this.</p>
