cURL / Mailing Lists / curl-library / Single Mail


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

From: Dan Fandrich <>
Date: Wed, 11 May 2011 12:37:08 -0700

On Wed, May 11, 2011 at 03:47:44PM +0100, Matt Horrocks wrote:
> 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?

There could be several reasons why a connection couldn't be made, so there's
no single timeout that would occur. But you can generate the most common case
by referencing a host that is guaranteed not to be listening, such as one
from an IP range that is guaranteed never to be assigned, like

> 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?

A proxy server will connect almost immediately, then pause with its response
until the remote host is determined not to be available and only then respond
with an HTTP 504 timeout error. So it's a completely different scenario.

>>> Dan

List admin:
Received on 2011-05-11