curl-library
'Couldn't resolve host' error since relocating server
Date: Wed, 19 Aug 2009 09:42:16 +0200
Hey,
My company moved last friday and thus so did our development server. The
problem is that since the relocation my (multi) cUrl script doesn't work
anymore.
It hangs on curl_multi_select() because it can't resolve the hostname.
However the CLI of curl works perfectly so I checked the configs (the
development server is an plain (arch)linux - apache - php installation) but
they seem clean. If I comment out the direction to our own dns server in
/etc/resolve.conf the CLI version also stops working so I figure out that
libcurl/php uses another way to resolve eg. via glibc?
So I ran the exact same code (simple curl http get action) on another
machine (with almost same configurations) and it works perfectly.
Using the options CURLOPT_DNS_USE_GLOBAL_CACHE and CURLOPT_DNS_CACHE_TIMEOUT
does not make any differance.
The test code:
$_h = curl_init();
curl_setopt($_h, CURLOPT_HEADER, 1);
curl_setopt($_h, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($_h, CURLOPT_HTTPGET, 1);
curl_setopt($_h, CURLOPT_URL, 'http://www.dns.be/' );
curl_setopt($_h, CURLOPT_DNS_USE_GLOBAL_CACHE, false );
curl_setopt($_h, CURLOPT_DNS_CACHE_TIMEOUT, 2 );
var_dump(curl_exec($_h));
var_dump(curl_getinfo($_h));
var_dump(curl_error($_h));
I found out that when I add the requested domain to my /etc/hosts file (and
thus bypass any dns requests), curl runs and return just fine. So probably
the error is somewhere in dns/bind? My /etc/host.conf lookup order is
'hosts,bind'.
Even worse: if I run 'host dns.be' it returns the requested dns data. which
normaly uses the same routines as gethostbyname() (the c function curl uses
for this).
So this could mean this is perhaps not a dns/bind problem and a fault in how
curl caches dns data or handles ipv4/ipv6 adresses?
I first thought is was a problem with the new glibc version (updated to 2.10
today) but the problem also occured when running glibc 2.8 this morning. See
this : http://udrepper.livejournal.com/20948.html on the 2.10 problem. The
suggested workarounds do not work for me (I saw this comming up i a lot of
forums)
Is there someone familiar with this kind of problems?
I really need this to work again.
Thanks in advance,
Tom Van de Putte
Received on 2009-08-19