libcurl Error Codes

Overview

This MAN page includes most, if not all, available error codes in libcurl. Why they occur and possibly what actions can be performed to fix the problem are also included. There are three types of CURL codes:

CURL Codes

Almost all "easy" interface functions return a CURLcode error code. No matter what, using the curl_easy_setopt option CURLOPT_ERRORBUFFER is a good practice as it will provide you with a human-readable error string that may offer more information about the cause of the error than just the error code. curl_easy_strerror can be called to get an error string from a given CURLcode number.

CURLcode is one of the following (CURLcode number in parentheses):

CURLE_OK (0)

All fine. Proceed as usual.

CURLE_UNSUPPORTED_PROTOCOL (1)

The URL you passed to libcurl used a protocol that this libcurl does not support. Cafe libcurl currently only support HTTP (and HTTPS).

CURLE_FAILED_INIT (2)

Early initialization code failed. This is likely to be an internal error or problem, or a resource problem where something fundamental couldn't get done at init time.

CURLE_URL_MALFORMAT (3)

The URL was not properly formatted.

CURLE_NOT_BUILT_IN (4)

A requested feature, protocol or option was not found built-in in this libcurl due to a build-time decision. This indicates that a feature or option is not available in Cafe.

CURLE_COULDNT_RESOLVE_PROXY (5)

Couldn't resolve proxy. The given proxy host could not be resolved.

CURLE_COULDNT_RESOLVE_HOST (6)

Couldn't resolve host. The given remote host was not resolved.

CURLE_COULDNT_CONNECT (7)

Failed to connect to host or proxy.

CURLE_REMOTE_ACCESS_DENIED (9)

We were denied access to the resource given in the URL.

CURLE_PARTIAL_FILE (18)

A file transfer was shorter or larger than expected. This happens when the server first reports an expected transfer size, and then delivers data that does not match the previously given size.

CURLE_HTTP_RETURNED_ERROR (22)

This is returned if CURLOPT_FAILONERROR is set TRUE and the HTTP server returns an error code that is >= 400.

CURLE_WRITE_ERROR (23)

An error occurred when an error was returned to libcurl from a write callback.

CURLE_UPLOAD_FAILED (25)

Failed starting the upload. The error buffer usually contains the server's description for this.

CURLE_READ_ERROR (26)

An error returned by the read callback.

CURLE_OUT_OF_MEMORY (27)

A memory allocation request failed. If occurs, indicates a serious error that events are severely affected.

CURLE_OPERATION_TIMEDOUT (28)

Operation timeout. The specified time-out period was reached according to the conditions.

CURLE_RANGE_ERROR (33)

The server does not support or accept range requests.

CURLE_HTTP_POST_ERROR (34)

This is an odd error that mainly occurs due to internal confusion.

CURLE_SSL_CONNECT_ERROR (35)

A problem occurred somewhere in the SSL/TLS handshake. You want the error buffer and read the message there as it pinpoints the problem slightly more. Could be certificates and others.

CURLE_BAD_DOWNLOAD_RESUME (36)

The download could not be resumed because the specified offset was out of the file boundary.

CURLE_ABORTED_BY_CALLBACK (42)

Aborted by callback. A callback returned "abort" to libcurl.

CURLE_BAD_FUNCTION_ARGUMENT (43)

Internal error. A function was called with a bad parameter.

CURLE_TOO_MANY_REDIRECTS (47)

Too many redirects. When following redirects, libcurl reached the maximum amount. Set your limit with CURLOPT_MAXREDIRS.

CURLE_UNKNOWN_OPTION (48)

An option passed to libcurl is not recognized/known. Refer to the appropriate documentation. This is most likely a problem in the program that uses libcurl. The error buffer might contain more specific information about which exact option it concerns.

CURLE_PEER_FAILED_VERIFICATION (51)

The remote server's SSL certificate or SSH md5 fingerprint was deemed not acceptable.

CURLE_GOT_NOTHING (52)

Nothing was returned from the server, and under the circumstances, getting nothing is considered an error.

CURLE_SEND_ERROR (55)

Failed sending network data.

CURLE_RECV_ERROR (56)

Failure with receiving network data.

CURLE_SSL_CERTPROBLEM (58)

Issue with the local client certificate.

CURLE_SSL_CACERT (60)

Peer certificate cannot be authenticated with known CA certificates.

CURLE_BAD_CONTENT_ENCODING (61)

Unrecognized transfer encoding.

CURLE_FILESIZE_EXCEEDED (63)

Maximum file size exceeded.

CURLE_SEND_FAIL_REWIND (65)

When performing a send operation curl had to rewind the data to retransmit, but the rewinding operation failed.

CURLE_LOGIN_DENIED (67)

The remote server denied curl to log in.

CURLE_CONV_FAILED (75)

Character conversion failed.

CURLE_CONV_REQD (76)

Caller must register conversion callbacks.

CURLE_REMOTE_FILE_NOT_FOUND (78)

The resource referenced in the URL does not exist.

CURLE_SSL_SHUTDOWN_FAILED (80)

Failed to shut down the SSL connection.

CURLE_AGAIN (81)

Socket is not ready for send/recv wait till it is ready and try again. This return code is only returned from curl_easy_recv and curl_easy_send.

CURLE_CHUNK_FAILED (88)

Chunk callback reported error.

CURLE_OBSOLETE*

These error codes will never be returned. They were used in an old libcurl version and are currently unused.

CURLM Codes

This is the generic return code used by functions in the libcurl multi interface. Also consider curl_multi_strerror.

CURLM_CALL_MULTI_PERFORM (-1)

This is not an error. It indicates that you should call curl_multi_perform again without doing select or similar in between.

CURLM_OK (0)

Things are as expected.

CURLM_BAD_HANDLE (1)

The passed-in handle is not a valid CURLM handle.

CURLM_BAD_EASY_HANDLE (2)

An easy handle was not good/valid. It could indicate that it is not an easy handle, or possibly, that the handle is already in use by this or another multi-handle.

CURLM_OUT_OF_MEMORY (3)

Out of memory.

CURLM_INTERNAL_ERROR (4)

This can only be returned if libcurl bugs. Please report it to us!

CURLM_BAD_SOCKET (5)

The passed-in socket is not a valid one that libcurl already knows about.

CURLM_UNKNOWN_OPTION (6)

curl_multi_setopt with unsupported option.

CURLSH Codes

The "share" interface will return a CURLSHcode to indicate when an error has occurred. Also consider curl_share_strerror.

CURLSHE_OK (0)

All as expected. Proceed as usual.

CURLSHE_BAD_OPTION (1)

An invalid option was passed to the function.

CURLSHE_IN_USE (2)

The share object is currently in use.

CURLSHE_INVALID (3)

An invalid share object was passed to the function.

CURLSHE_NOMEM (4)

Not enough memory was available.

See Also

HTTP Client Library (libcurl)

Revision History

2013/09/12 Converted.


CONFIDENTIAL