---
name: "CURLINFO_OS_ERRNO"
section: "3"
platform: "macos"
package: "curl"
version: "166.0.0.0.1"
release: "macOS 26.5"
platforms: ["linux", "macos"]
url: "https://new.carta.tech/CURLINFO_OS_ERRNO"
---

# CURLINFO\_OS\_ERRNO(3)

get errno number from last connect failure

## NAME

CURLINFO\_OS\_ERRNO - get errno number from last connect failure

## SYNOPSIS

```
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_OS_ERRNO, long *errnop);
```

## DESCRIPTION

Pass a pointer to a long to receive the errno variable from a connect failure. Note that the value is only set on failure, it is not reset upon a successful operation. The number is OS and system specific.

## PROTOCOLS

All

## EXAMPLE

```
int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode res;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
    res = curl_easy_perform(curl);
    if(res != CURLE_OK) {
      long error;
      res = curl_easy_getinfo(curl, CURLINFO_OS_ERRNO, &error);
      if(res && error) {
        printf("Errno: %ld\n", error);
      }
    }
    curl_easy_cleanup(curl);
  }
}
```

## AVAILABILITY

Added in 7.12.2

## RETURN VALUE

Returns CURLE\_OK if the option is supported, and CURLE\_UNKNOWN\_OPTION if not.

## SEE ALSO

[**curl\_easy\_getinfo**(3)](/curl_easy_getinfo/3.md), [**curl\_easy\_setopt**(3)](/curl_easy_setopt/3.md)
