title: How to fix django.db.utils.OperationalError: could not translate host name "db" to address: Temporary failure in name resolution
body: <p>Seen this question already asked but still no solution working for me.</p>
  <p>My docker-compose:</p>
  <pre><code>version: '3.9'
  
  services:
    db:
      image: postgres
      volumes: 
        - ./data/db:/var/lib/postgresql/data
      environment:
        - POSTGRES_DB=postgres
        - POSTGRES_USER=postgres
        - POSTGREES_PASSWORD=password
  
    web:
      build: .
      command: python manage.py runserver 0.0.0.0:8000
      volumes:
        - .:/books
      ports:
        - &quot;8000:8000&quot;
      depends_on:
        - db
  </code></pre>
  <p>my requirements.txt</p>
  <pre><code>Django&gt;=3.2
  psycopg2-binary&gt;=2.8
  </code></pre>
  <p>my settings.py:</p>
  <pre><code>DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.postgresql',
          'NAME': 'postgres',
          'USER' : 'postgres',
          'PASSWORD' : 'postgres',
          'HOST' : 'db',
          'PORT' : 5432,
      }
  }
  </code></pre>
  <p>my dockerfile:</p>
  <pre><code>FROM python:3
  ENV PYTHONUNBUFFERED=1
  WORKDIR /books
  COPY requirements.txt /books/
  RUN pip install -r requirements.txt
  COPY . /books/
  
  </code></pre>
  <p>the error that is showing  on my terminal</p>
  <pre><code>File &quot;/usr/local/lib/python3.10/site-packages/psycopg2/__init__.py&quot;, line 122, in connect
  web_1  |     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
  web_1  | django.db.utils.OperationalError: could not translate host name &quot;db&quot; to address: Temporary failure in name resolution
  </code></pre>