Updated on 2026-08-03 GMT+08:00

libcurl Status Codes (SDK for C)

Overview

The OBS SDK FOR C implements HTTP communication based on libcurl. If curl_easy_perform fails to be executed, the SDK records the libcurl status code (CURLcode) and error information in the log. The format is as follows:

curl_easy_perform failed, CURLcode = 6, curl_error_message is 'Could not resolve host', obs_status = NameLookupError(5), curlErrorBuffer = ...

The key fields are described as follows:

Field

Description

CURLcode

Status code returned by libcurl, which is used to locate underlying network, SSL, or protocol errors

curl_error_message

Error message provided by libcurl

obs_status

OBS status code mapped from CURLcode by the SDK

curlErrorBuffer

Detailed error buffer information of libcurl

Mapping from CURLcode to OBS Status Codes in the SDK

The SDK uses the request_curl_code_to_status function to map CURLcode to OBS status codes. The mapping is as follows:

CURLcode

Value

curl_error_message

Mapped OBS Status Code

Description

CURLE_OK

0

No error

OBS_STATUS_OK

Request succeeded.

CURLE_OUT_OF_MEMORY

-1

Out of memory

OBS_STATUS_OutOfMemory

Memory allocation failed.

CURLE_COULDNT_RESOLVE_PROXY

5

Couldn't resolve proxy name

OBS_STATUS_NameLookupError

Proxy domain name resolution failed.

CURLE_COULDNT_RESOLVE_HOST

6

Couldn't resolve host name

OBS_STATUS_NameLookupError

Server domain name resolution failed.

CURLE_COULDNT_CONNECT

7

Failed to connect to host or proxy

OBS_STATUS_FailedToConnect

Connection to the server or proxy failed.

CURLE_WRITE_ERROR

23

Write error

OBS_STATUS_ConnectionFailed

Data write failed.

CURLE_OPERATION_TIMEDOUT

28

Operation timeout

OBS_STATUS_ConnectionFailed

Operation timed out.

CURLE_PARTIAL_FILE

18

Transferred a partial file

OBS_STATUS_PartialFile

The file is not completely transferred.

CURLE_SSL_CACERT

60

SSL certificate problem

OBS_STATUS_ServerFailedVerification

SSL certificate verification failed.

Others

-

-

OBS_STATUS_InternalError

Errors that are not explicitly mapped by the SDK are classified as internal errors.

Common CURLcode Fault Locating Guide

CURLE_COULDNT_RESOLVE_HOST (6)

Symptom: The log contains "CURLcode = 6, curl_error_message is 'Could not resolve host'".

Possible causes:

  1. The DNS configuration is incorrect. As a result, the domain name of the OBS server cannot be resolved.
  2. The network is disconnected or the DNS server is unreachable.
  3. The host_name parameter is incorrectly configured (for example, the spelling is incorrect or the domain name suffix is missing).
  4. The DNS server configuration in the /etc/resolv.conf file is incorrect.

Fault locating procedure:

  1. Check whether the value of options.bucket_options.host_name is correct. It should be the domain name of the OBS server, for example, obs.cn-north-4.myhuaweicloud.com.
  2. Run the nslookup obs.cn-north-4.myhuaweicloud.com command on the server to verify DNS resolution.
  3. Check the DNS server configuration in the /etc/resolv.conf file.
  4. Add the IP address mapping of the OBS server to the /etc/hosts file for temporary verification.

CURLE_COULDNT_CONNECT (7)

Symptom: The log contains "CURLcode = 7, curl_error_message is 'Failed to connect to host or proxy'".

Possible causes:

  1. The network is disconnected, and the TCP connection to the OBS server cannot be established.
  2. The firewall or security group rules block outbound access.
  3. The proxy configuration is incorrect.
  4. The OBS server ports (80 for HTTP and 443 for HTTPS) are blocked.

Fault locating procedure:

  1. Run the telnet obs.cn-north-4.myhuaweicloud.com 443 command to verify the TCP connectivity.
  2. Check the firewall rules and security group configurations to ensure that outbound traffic on port 443 is allowed.
  3. If a proxy is used, check whether options.request_options.proxy_host is correctly configured.
  4. Run the curl -v https://obs.cn-north-4.myhuaweicloud.com command to test the connectivity.

CURLE_OPERATION_TIMEDOUT (28)

Symptom: The log contains "CURLcode = 28, curl_error_message is 'Operation timeout'".

Possible causes:

  1. The network latency is too high, and the request is not completed within the specified timeout interval.
  2. The timeout interval specified for uploading or downloading large files is too short.
  3. The server responds slowly.
  4. The rate limit is too low. As a result, the transmission times out.

Fault locating procedure:

  1. Check whether options.request_options.connect_time (connection timeout interval, in seconds) is set properly.
  2. Check the settings of options.request_options.speed_time and speed_limit.
  3. For large file transfer, increase the values of connect_time and max_connected_time.
  4. Check the network bandwidth and latency.

CURLE_SSL_CACERT (60)

Symptom: The log contains "CURLcode = 60, curl_error_message is 'SSL certificate problem'".

Possible causes:

  1. The server does not have the CA certificate package.
  2. The certificate file specified by options.request_options.server_cert_path does not exist or is in an incorrect format.
  3. A man-in-the-middle (MITM) attack occurs or the certificate is tampered with.
  4. libcurl is not properly linked with OpenSSL during compilation.

Fault locating procedure:

  1. Run the ls /etc/ssl/certs/ command to check whether the CA certificate package is installed.
  2. If server_cert_path is set, verify the certificate file path and certificate format.
  3. Run the curl -v https://obs.cn-north-4.myhuaweicloud.com command to verify the SSL handshake.
  4. To skip certificate verification (only in the test environment), check whether related options are enabled during compilation.

CURLE_PARTIAL_FILE (18)

Symptom: The log contains "CURLcode = 18, curl_error_message is 'Transferred a partial file'".

Possible causes:

  1. The network is disconnected during transmission.
  2. The connection is closed on the server in advance.
  3. The disk space is insufficient. As a result, the write operation fails.
  4. The connection is unstable when a large file is downloaded.

Fault locating procedure:

  1. Check the network stability.
  2. Check whether the disk space is insufficient.
  3. Use the resumable download API (download_file) to download large files.
  4. Check whether the value of Content-Length returned by the server is the same as the actual data volume.

CURLE_WRITE_ERROR (23)

Symptom: The log contains "CURLcode = 23, curl_error_message is 'Write error'".

Possible causes:

  1. The callback function returns an error, causing the write operation to be aborted.
  2. Data fails to be written to the local disk.
  3. An exception occurs during the execution of the callback function.

Fault locating procedure:

  1. Check the logic of the put_object_data_callback or get_object_data_callback callback function.
  2. Verify that the callback function returns the correct value. (The upload callback should return the number of written bytes. Any non-zero status code indicates an error.)
  3. Check the disk space and file permissions.

CURLE_OUT_OF_MEMORY (-1/other values)

Symptom: The log contains "CURLcode = -1" or memory-related errors.

Possible causes:

  1. The available system memory is insufficient.
  2. The buffer fails to be allocated when a large file is uploaded.
  3. The available memory decreases due to memory leakage.

Fault locating procedure:

  1. Run the free -m command to check the system memory usage.
  2. Use multipart upload instead of one-off upload to upload large files.
  3. Check whether memory leakage occurs.
  4. Adjust the value of options.request_options.buffer_size.

CURLE_COULDNT_RESOLVE_PROXY (5)

Symptom: The log contains "CURLcode = 5, curl_error_message is 'Couldn't resolve proxy name'."

Possible causes:

  1. The proxy server domain name is incorrectly configured.
  2. The proxy server domain name cannot be resolved.

Fault locating procedure:

  1. Check the options.request_options.proxy_host configuration format. The format must be hostname:port or http://hostname:port.
  2. Run the nslookup command to verify the proxy domain name resolution.
  3. If no proxy is required, ensure that proxy_host is not set.

CURLcode Troubleshooting Procedure in Logs

  1. Find CURLcode = X in the SDK logs.
  2. Based on X, refer to this document to determine the error type.
  3. Locate and rectify the fault according to the corresponding locating procedure.
  4. If the returned CURLcode is not in the mapping table of this document, the error is not explicitly mapped. In this case, the SDK returns OBS_STATUS_InternalError. For details, see the official libcurl documentation.