title: django.db.utils.OperationalError: (2002, "Can't connect to MySQL server on 'db' (115)")
body: <p>This has already been asked, but none of the answers have helped me. This is my configuration. Im running docker-compose with two services, a web app in django and the database in mariadb. I can connect normally to my local db with this exact configuration, only changing the host in settings.py to localhost. When i run <code>docker-compose up</code>, the web service stops immediately after trying to connect to the database, and return this error.</p>
  
  <p><code>django.db.utils.OperationalError: (2002, "Can't connect to MySQL server on 'db' (115)")</code></p>
  
  <p><strong>Dockerfile</strong></p>
  
  <pre><code>FROM python:3.7
  
  RUN mkdir /app
  
  COPY requierments.txt /app/
  
  WORKDIR /app
  
  RUN pip install -r requierments.txt
  
  COPY . /app/
  </code></pre>
  
  <p><strong>docker-compose.yml</strong></p>
  
  <pre><code>version: '3'
  
  services:
    db:
      image: mariadb:10.2
      expose:
        - 3306
      ports:
        - "3306:3306"
      environment:
        MYSQL_DATABASE: 'django_backend'
        MYSQL_USER: 'django'
        MYSQL_PORT: '3306'
        MYSQL_PASSWORD: 'mysql1234pass'
        MYSQL_ROOT_PASSWORD: 'password'
  
    web:
      build: .
      image: backendblockchain_web
      volumes:
        - .:/app
      ports:
        - "8000:8000"
      depends_on:
        - db
      links:
        - db
      command:
        - /bin/bash
        - -c
        - |
          sleep 10
          python3 manage.py migrate
          python3 manage.py runserver 0.0.0.0:8000
  </code></pre>
  
  <p><strong>setting.py</strong></p>
  
  <pre><code>DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.mysql',
          'NAME': 'django_backend',
          'USER': 'django',
          'PASSWORD': 'mysql1234pass',
          'HOST': 'db',
          'PORT': '3306'
      }
  }
  </code></pre>