cURL / Mailing Lists / curl-library / Single Mail


RE: curl with c-ares returns "(Could not contact DNS servers)"

From: David Cook <>
Date: Fri, 4 Feb 2011 02:05:02 +0000


I found the source of the problem.

By default, my nsswitch.conf file didn't have the hosts: dns option. So I had to add it manually and burn it into the distribution. I now find it strange that dns was working without c-ares. none of my conf file had any dns lookup option.

Thanx all for your help!


Subject: RE: curl with c-ares returns "(Could not contact DNS servers)"
Date: Thu, 3 Feb 2011 22:30:41 +0000


Ok I've been debugging. Here's some info before I start running the tests.

1) I noticed that Curl_getaddrInfo() in Curl_resolv(). This function calls ares_gethostbyname which down the stack reads /etc/hosts. The channel settings have one lookups ('f') for one file lookup and nserver is set to 1 (i really have one dns server in /etc/resolv.conf). I would have expected to have an entry for dns lookup ('b'). Do you have an opinion on this? My /etc/resolv.conf does not have any lookup entries.

2) The file lookup functions read /etc/hosts to see if there's a match for the IP address I'm looking for. However, my /etc/hosts file only has one entry: rtl8181

This entry has nothing to do with the host name I'm looking for.

3) /etc/hosts is not writable on this system. I only have one writable partition (/opt). Is this a problem?


> Date: Thu, 3 Feb 2011 13:44:57 -0800
> From:
> To:
> Subject: Re: curl with c-ares returns "(Could not contact DNS servers)"
> On Thu, Feb 03, 2011 at 09:22:02PM +0000, David Cook wrote:
> > Ok I looked into the c-ares library and could not find the 3 tests you are
> > talking about. I noticed that there are several tests in curl-x/tests/data.
> > Which ones are you referring to?
> There are three test programs included in the c-ares source: acountry, adig
> & ahost. If curl itself is failing with c-ares, then naturally (hopefully) the
> curl tests will show failures. But, trying those three c-ares example programs
> will isolate the problem to c-ares or curl.
> >>> Dan
> -------------------------------------------------------------------
> List admin:
> Etiquette:

List admin:

List admin:
Received on 2011-02-04