title: Elasticsearch with Yii 2.0: Error: Elasticsearch request failed: 7 - Failed to connect to ##.##.##.### port 9200: Connection refused
body: <p>I have Elasticsearch properly configured on my server. I can do everything from the command line using cURL. I can even connect to it using cURL from a PHP script outside Yii. However, I can't seem to get it to work from within Yii 2.0.</p>
  
  <p>In my config, I have:</p>
  
  <pre><code>'elasticsearch' =&gt; [
              'class' =&gt; 'yii\elasticsearch\Connection',
              'nodes' =&gt; [
                  ['http_address' =&gt; 'localhost:9200'],
                  // configure more hosts if you have a cluster
              ],
          ],
  </code></pre>
  
  <p>But when I try to do a simple query in Yii, I get this error. Note how it's using my server ip address rather than 'localhost' or '172.0.0.1'. Note: I've hashed out my ip address for sercurity.</p>
  
  <pre><code>Elasticsearch Database Exception – yii\elasticsearch\Exception
  Elasticsearch request failed: 7 - Failed to connect to ##.##.##.### port 9200: Connection refused
  Error Info: Array
  (
      [requestMethod] =&gt; GET
      [requestUrl] =&gt; http://##.##.##.###:9200/profiles/profile/_search
      [requestBody] =&gt; {"size":100,"query":{"match_all":{}}}
      [responseHeaders] =&gt; Array
          (
          )
      [responseBody] =&gt; 
  )
  </code></pre>