title: Django + ElasticSearch + Docker - Connection Timeout no matter what hostname I use
body: <p>I'm having issues connecting with my Elasticsearch container since day 1.
  First I was using elasticsearch as the hostname, then I've tried the container name web_elasticsearch_1, and finally I'd set a Static IP address to the container and passed it in my configuration file.</p>
  <p>PYPI packages:</p>
  <ul>
  <li>django==3.2.9</li>
  <li>elasticsearch==7.15.1</li>
  <li>elasticsearch-dsl==7.4.0</li>
  </ul>
  <p><strong>docker-compose.yml</strong></p>
  <pre><code>version: &quot;3.3&quot;
  
  services:
  
    web:
      build:
        context: .
        dockerfile: local/Dockerfile
      image: project32439/python
      command: python manage.py runserver 0.0.0.0:8000
      volumes:
        - .:/code
      ports:
        - &quot;8000:8000&quot;
      env_file:
        - local/python.env
      depends_on:
        - elasticsearch
  
    elasticsearch:
      image: elasticsearch:7.10.1
      environment:
        - xpack.security.enabled=false
        - discovery.type=single-node
      networks:
        default:
          ipv4_address: 172.18.0.10
  </code></pre>
  <p><strong>settings.py</strong></p>
  <pre><code># Elasticsearch
  ELASTICSEARCH_HOST = &quot;172.18.0.10&quot;
  ELASTICSEARCH_PORT = 9200
  </code></pre>
  <p><strong>service.py</strong></p>
  <pre><code>from django.conf import settings
  from elasticsearch import Elasticsearch, RequestsHttpConnection
  
  es = Elasticsearch(
      hosts=[{&quot;host&quot;: settings.ELASTICSEARCH_HOST, &quot;port&quot;: settings.ELASTICSEARCH_PORT}],
      use_ssl=False,
      verify_certs=False,
      connection_class=RequestsHttpConnection,
  )
  </code></pre>
  <p><strong>traceback</strong></p>
  <pre><code>HTTPConnectionPool(host='172.18.0.10', port=9200): Max retries exceeded with url: / (Caused by ConnectTimeoutError(&lt;urllib3.connection.HTTPConnection object at 0x7f1973ebd6d0&gt;, 'Connection to 172.18.0.10 timed out. (connect timeout=5)'))
  </code></pre>