title: Kibana on Docker cannot connect to Elasticsearch
body: <p>I tried to create Kibana and Elasticsearch and it seems that Kibana is having trouble identifying Elasticsearch.</p>
  
  <p>Here are my steps:</p>
  
  <p>1) Create network </p>
  
  <pre><code>docker network create mynetwork --driver=bridge
  </code></pre>
  
  <p>2) Run Elasticsearch Container</p>
  
  <pre><code>docker run -d -p 9200:9200 -p 9300:9300 --name elasticsearch_2_4 --network mynetwork elasticsearch:2.4
  </code></pre>
  
  <p>3) Run Kibana Container</p>
  
  <pre><code>docker run -i --network mynetwork -p 5601:5601 kibana:4.6
  </code></pre>
  
  <p>I get a JSON output when I connect to Elasticsearch via <a href="http://localhost:9200/" rel="noreferrer">http://localhost:9200/</a> through my browser.</p>
  
  <p>But when I open <a href="http://localhost:5601/" rel="noreferrer">http://localhost:5601/</a> I get </p>
  
  <pre><code>Unable to connect to Elasticsearch at http://elasticsearch:9200.
  </code></pre>
  
  <p><strong>Alternate Approach,</strong></p>
  
  <p>I still get a similar error when I try</p>
  
  <pre><code>docker run -d -e ELASTICSEARCH_URL=http://127.0.0.1:9200 -p 5601:5601 kibana:4.6
  </code></pre>
  
  <p>where I get the error</p>
  
  <pre><code>Unable to connect to Elasticsearch at http://127.0.0.1:9200.
  </code></pre>
  
  <hr>
  
  <p>My blog post based on the accepted answer: <a href="https://gunith.github.io/docker-kibana-elasticsearch/" rel="noreferrer">https://gunith.github.io/docker-kibana-elasticsearch/</a></p>