title: How to solve CURL request error "Could not resolve host: ..." PHP?
body: <p>I'm facing this very odd error. I can't send a cURL request anymore after changing nothing. Out of the sudden I'm getting:</p>
  
  <blockquote>
    <p>'Could not resolve host: hostname'</p>
  </blockquote>
  
  <p>I know there are like a 1000 instances of this question on stackoverflow but I have tried all the suggested answers/comments in them for the past 5 hours and nothing seems to work. This is my code for the request:</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  class APIService
  {
      private $host;
      private $key;
  
      function __construct($host, $key)
      {
          $this-&gt;host = $host;
          $this-&gt;key = $key;
      }
  
      function curlRequest($config)
      {
          $ch = curl_init();
          curl_setopt($ch, CURLOPT_HTTPHEADER, array('api:'.$this-&gt;key));
          curl_setopt($ch, CURLOPT_URL, $this-&gt;host.$config);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          $curlSession = curl_exec($ch);
  
          return $this-&gt;decodeJSON($curlSession);
      }
  
      function getSomeList()
      {
          return $this-&gt;curlRequest('/folder/list');
      }
  
      private function decodeJSON($someList)
      {
          return json_decode($someList, true);
      }
  }
  
  </code></pre>
  
  <p>The host is local and using <code>docker ps</code> I can see that is running. Everything worked fine a few days ago and I made absloutly no changes to it or to any component that may have an effect on it but it doesn't work out of the sudden. Has anyone has any ideas why this is happening and how I could fix it?</p>