Results 1 to 2 of 2

Thread: Curl_exec error: Couldn't resolve host

  1. #1
    belltown is offline x10Hosting Member
    Join Date
    Mar 2008
    Location
    39.109871N,76.769736W
    Posts
    95

    Curl_exec error: Couldn't resolve host

    I have a PHP script which uses cURL to retrieve maps from Google. Until yesterday it was working fine. Now, every once in while I get a curl error: "Couldn't resolve host 'maps.google.com'". Some of the time it works, some of the time it doesn't.

    Here is a short script that reproduces the problem:

    Code:
    <?php
    /*
     * http://belltown.x10hosting.com/test.php
     */
    $url = "http://maps.google.com/maps/api/staticmap?".
              "center=seattle,wa&".
              "zoom=13&".
              "size=640x640&".
              "maptype=roadmap&".
              "format=jpg&".
              "mobile=true&".
              "sensor=false";
    if (($c = curl_init ($url)) === false) die ("curl_init error: ".curl_error ($c));
    if (curl_exec ($c) === false) die ("curl_exec error: ".curl_error ($c));
     
    curl_close ($c);          
    ?>
    Sometimes it returns a map, sometimes it returns the following error:

    Code:
    curl_exec error: Couldn't resolve host 'maps.google.com'
    I wonder if this is related to the problems absolut has been having lately. Any ideas?

  2. #2
    belltown is offline x10Hosting Member
    Join Date
    Mar 2008
    Location
    39.109871N,76.769736W
    Posts
    95

    Re: Curl_exec error: Couldn't resolve host

    Upon further investigation, it appears that the DNS resolution on the absolut Apache server is not working consistently. Here's another test script show that 2 out of 10 times, the server failed to return a valid IP address when gethostbyname was called from a PHP script.

    Here's the script:

    Code:
    <?php
    /*
     * http://belltown.x10hosting.com/test.php
     */
    $host = 'maps.google.com';
    echo "Looking up: $host<br><br>";
    for ($i = 0; $i < 10; $i++) {
     $ip = gethostbyname($host);
     if ($ip == $host) {
      echo "Unable to resolve host name<br>";
     }
     else {
      echo "IP address: $ip<br>";
     }
     sleep (5);
    }
    ?>
    And here's the output:

    Code:
    Looking up: maps.google.com
     
    IP address: 74.125.95.104
    IP address: 74.125.95.147
    IP address: 74.125.95.103
    Unable to resolve host name
    IP address: 74.125.95.105
    Unable to resolve host name
    IP address: 74.125.95.99
    IP address: 74.125.95.147
    IP address: 74.125.95.105
    IP address: 74.125.95.106

Similar Threads

  1. Error with Wordpress on host...
    By arminrt in forum Free Hosting
    Replies: 1
    Last Post: 04-05-2010, 01:13 PM
  2. Cannot Resolve Host name : CSS
    By hamsn in forum Free Hosting
    Replies: 4
    Last Post: 12-13-2008, 05:32 AM
  3. Replies: 1
    Last Post: 11-19-2008, 04:51 AM
  4. Error en mi host
    By roonline in forum Free Hosting
    Replies: 17
    Last Post: 11-14-2007, 03:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
dedicated servers