title: Guzzle / Laravel cURL error 6: Could not resolve host: api.coingecko.com
body: <p>Ok so I am a little stuck with this issue. I have a foreach loop (usually 50 results) that queries an API using Guzzle via Laravel Http and I am getting really inconsistent results.</p>
  <p>I monitor the inserts in the database as they come in and sometimes the process seems slow and other times the process will fail with the following after x number of returned results.</p>
  <blockquote>
  <p>cURL error 6: Could not resolve host: api.coingecko.com</p>
  </blockquote>
  <p>The following is the actual code im using to fetch the results.</p>
  <pre><code>foreach ($json_result as $account) {
  
                      var_dump($account['name']);
  
                      $name = $account['name'];
                      $coingecko_id = $account['id'];
                      $identifier = strtoupper($account['symbol']);
  
                      $response_2 = Http::get('https://api.coingecko.com/api/v3/coins/'.urlencode($coingecko_id).'?localization=false');
  
                      if($response_2-&gt;successful()){
  
                          $json_result_extra_details = $response_2-&gt;json();
  
                          if( isset($json_result_extra_details['description']['en']) ){
                              $description = $json_result_extra_details['description']['en'];
                          }
  
                          if( isset($json_result_extra_details['links']['twitter_screen_name']) ){
                              $twitter_screen_name = $json_result_extra_details['links']['twitter_screen_name'];
                          }
                          
                      }else {
                          // Throw an exception if a client or server error occurred...
                          $response_2-&gt;throw();
                      }
  
                      $crypto_account = CryptoAccount::updateOrCreate(
                          [
                              'identifier' =&gt; $identifier
                          ],
                          [
                              'name' =&gt; $name,
                              'identifier' =&gt; $identifier,
                              'type' =&gt; &quot;cryptocurrency&quot;,
                              'coingecko_id' =&gt; $coingecko_id,
                              'description' =&gt; $description,
                          ]);
  
                      //sleep(1);
      
                  }
  </code></pre>
  <p>Now I know I am within the API rate limit of 100 calls a minute so I don't think that is the issue. I am wondering if this is a server/api issue which I don't really have any control over or if it related to my code and how Guzzle is implemented.</p>
  <p>When I do single queries I don't seem to have a problem, the issue seems to be when it is inside the foreach loop.</p>
  <p>Any advice would be great. Thanks</p>
  <p><strong>EDIT</strong></p>
  <p>Ok to update the question, I am now wondering if this is Guzzle/Laravel related. I changed the API to now point to the Twitter API and I am getting the same error after 80 synchronous requests.</p>