I'm using `Django 2.x` and configuring it using `Docker`.

I'm using `postresql` database engine.

**Dockerfile** contents are

```
FROM python:3-alpine
RUN apk --update add libxml2-dev libxslt-dev libffi-dev gcc musl-dev libgcc curl
RUN apk add jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev postgresql-dev
RUN apk add --no-cache bash
ENV PYTHONUNBUFFERED 1
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
RUN set -ex && mkdir /app
COPY Pipfile /app
COPY Pipfile.lock /app
WORKDIR /app
RUN pip install pipenv
RUN pipenv install --system --deploy
ADD . /app/
RUN chmod +x start.sh

# Expose port
EXPOSE 9010

```

**docker-compose.yml** file contains

```
version: '3'

services:
  nginx:
    image: nginx:alpine
    container_name: "originor-nginx"
    ports:
      - "10080:80"
      - "10443:43"
    volumes:
      - .:/app
      - ./config/nginx:/etc/nginx/conf.d
    depends_on:
      - web
    networks:
      - originor_web_network
  web:
    build: .
    container_name: "originor-web"
    command: ./start.sh
    volumes:
      - .:/app
    ports:
      - "9010:9010"
    depends_on:
      - db
    networks:
      - originor_web_network
      - originor_db_network
  db:
    image: postgres:11
    container_name: "originor-postgres-schema"
    volumes:
      - originor_database:/var/lib/postgresql/data
    networks:
      - originor_db_network
    environment:
      - POSTGRES_USER=originor_schema_u
      - POSTGRES_PASSWORD=ADF45sa98SD9q9we8r34&
      - POSTGRES_DB=originor_schema

networks:
  originor_web_network:
    driver: bridge
  originor_db_network:
    driver: bridge

volumes:
  originor_database:

```

and Django settings.py file has

```
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'originor_schema',
        'USER': 'originor_schema_u',
        'PASSWORD': 'ADF45sa98SD9q9we8r34&',
        'HOST': 'db',
        'PORT': '5432',
    }
}

```

But when I run

```
docker-compose up

```

**It gives error as**

```
originor-web | django.db.utils.OperationalError: could not connect to server: Connection refused
originor-web |  Is the server running on host "db" (172.23.0.2) and accepting
originor-web |  TCP/IP connections on port 5432?

```