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

# CURLOPT\_DOH\_URL(3)

provide the DNS-over-HTTPS URL

## NAME

CURLOPT\_DOH\_URL - provide the DNS-over-HTTPS URL

## SYNOPSIS

```
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DOH_URL, char *URL);
```

## DESCRIPTION

Pass in a pointer to a *URL* for the DoH server to use for name resolving. The parameter should be a char pointer to a null-terminated string which must be a valid and correct HTTPS URL.

libcurl does not validate the syntax or use this variable until the transfer is issued. Even if you set a crazy value here, *[curl\_easy\_setopt(3)](/curl_easy_setopt/3.md)* still returns *CURLE\_OK*.

curl sends POST requests to the given DNS-over-HTTPS URL.

To find the DoH server itself, which might be specified using a name, libcurl uses the default name lookup function. You can bootstrap that by providing the address for the DoH server with *[CURLOPT\_RESOLVE(3)](/CURLOPT_RESOLVE/3.md)*.

Disable DoH use again by setting this option to NULL.

## INHERIT OPTIONS

DoH lookups use SSL and some SSL settings from your transfer are inherited, like *[CURLOPT\_SSL\_CTX\_FUNCTION(3)](/CURLOPT_SSL_CTX_FUNCTION/3.md)*.

The hostname and peer certificate verification settings are not inherited but can be controlled separately via *[CURLOPT\_DOH\_SSL\_VERIFYHOST(3)](/CURLOPT_DOH_SSL_VERIFYHOST/3.md)* and *[CURLOPT\_DOH\_SSL\_VERIFYPEER(3)](/CURLOPT_DOH_SSL_VERIFYPEER/3.md)*.

A set *[CURLOPT\_OPENSOCKETFUNCTION(3)](/CURLOPT_OPENSOCKETFUNCTION/3.md)* callback is not inherited.

## KNOWN BUGS

Even when DoH is set to be used with this option, there are still some name resolves that are performed without it, using the default name resolver mechanism. This includes name resolves done for *[CURLOPT\_INTERFACE(3)](/CURLOPT_INTERFACE/3.md)*, *[CURLOPT\_FTPPORT(3)](/CURLOPT_FTPPORT/3.md)*, a proxy type set to **CURLPROXY\_SOCKS4** or **CURLPROXY\_SOCKS5** and probably some more.

## DEFAULT

NULL - there is no default DoH URL. If this option is not set, libcurl uses the default name resolver.

## PROTOCOLS

All

## EXAMPLE

```
int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
    curl_easy_setopt(curl, CURLOPT_DOH_URL, "https://dns.example.com");
    curl_easy_perform(curl);
  }
}
```

## AVAILABILITY

Added in 7.62.0

## RETURN VALUE

Returns CURLE\_OK on success or CURLE\_OUT\_OF\_MEMORY if there was insufficient heap space.

Note that *[curl\_easy\_setopt(3)](/curl_easy_setopt/3.md)* does immediately parse the given string so when given a bad DoH URL, libcurl might not detect the problem until it later tries to resolve a name with it.

## SEE ALSO

[**CURLOPT\_DNS\_CACHE\_TIMEOUT**(3)](/CURLOPT_DNS_CACHE_TIMEOUT/3.md), [**CURLOPT\_RESOLVE**(3)](/CURLOPT_RESOLVE/3.md), [**CURLOPT\_VERBOSE**(3)](/CURLOPT_VERBOSE/3.md)
