cURL / Mailing Lists / curl-library / Single Mail


Advice on forcing a "Couldn't connect to host" and timeout error.

From: Matt Horrocks <>
Date: Wed, 11 May 2011 15:47:44 +0100


I am trying to work around some intermittent "Couldn't connect to host"
errors which appear when I'm using curl through PHP / curl multi_exec. The
knock on effect of these errors is the length of time curl waits before the
timeout occurs.

I have the following curl_setopt:

curl_setopt($i1, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($i1, CURLOPT_PROXY, $proxy);
curl_setopt($i1, CURLOPT_URL, $url);
curl_setopt($i1, CURLOPT_HEADER, 1);
curl_setopt($i1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($i1, CURLOPT_REFERER, $referer);
curl_setopt($i1, CURLOPT_USERAGENT, $agent);

(I guess) because I don't have CURLOPT_CONNECTTIMEOUT or CURLOPT_TIMEOUT set
that curl just sits and waits for the default timeout to occur before

I'd like to do some testing rather than just blindly adding
CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT values... so what would be best
way to force a "Couldn't connect to host" timeout error?

Is the error more likely to come from the proxy server or the $url that I'm
try to retrieve or is not possible to tell?


List admin:
Received on 2011-05-11