Repository navigation
Description
I did this
If I understand correctly, curl + c-ares doesn't work out of the box on Android because the system lacks an /etc/resolv.conf and newer Android releases blocks querying the net.dns properties, so you need to pass an explicit --dns-servers to curl for it to work.
What doesn't seem to work, though, is using --dns-servers + --doh-url:
Using no --dns-servers (don't work):
$ ./curl -v example.com
Note: Read config file from
Note: '/data/data/com.termux/files/home/.curlrc'
* Could not resolve host: example.com (Could not contact DNS servers)
* Could not resolve host: example.com
* Could not resolve: example.com:80
* closing connection #0
curl: (6) Could not resolve host: example.com (Could not contact DNS servers)
Using --dns-servers (works):
$ ./curl -v example.com --dns-servers 8.8.8.8
Note: Read config file from
Note: '/data/data/com.termux/files/home/.curlrc'
* Host example.com:80 was resolved.
* IPv6: 2606:4700:10::6814:179a, 2606:4700:10::ac42:93f3
* IPv4: 172.66.147.243, 104.20.23.154
* Trying [2606:4700:10::6814:179a]:80...
* Immediate connect fail for 2606:4700:10::6814:179a: Network is unreachable
* connect to 2606:4700:10::6814:179a port 80 from :: port 0 failed: Network is unreachable
* Trying 172.66.147.243:80...
* Trying [2606:4700:10::ac42:93f3]:80...
* Immediate connect fail for 2606:4700:10::ac42:93f3: Network is unreachable
* connect to 2606:4700:10::ac42:93f3 port 80 from :: port 0 failed: Network is unreachable
* Established connection to example.com (172.66.147.243 port 80) from 100.112.198.175 port 37482
[...]
Using --dns-servers + --doh-url (don't work):
$ ./curl -v example.com --dns-servers 8.8.8.8 --doh-url https://dns.google/dns-query
Note: Read config file from
Note: '/data/data/com.termux/files/home/.curlrc'
* Could not resolve host: example.com
* Could not resolve: example.com:80
* closing connection #0
curl: (6) Could not resolve host: example.com
So it seems to me that curl doesn't use --dns-servers to resolve its own DOH URL.
I expected the following
Using --dns-servers and --doh-url together on Android should work
curl/libcurl version
curl 8.23.0 (aarch64-none-linux-android24) libcurl/8.23.0 wolfSSL/5.9.4 zlib/1.2.13 c-ares/1.34.8
Release-Date: 2026-10-14
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns mqtt mqtts pop3 pop3s rtsp smtp smtps telnet tftp ws wss
Features: alt-svc AsynchDNS HSTS HTTPS-proxy IPv6 Largefile libz SSL threadsafe UnixSockets
operating system
Linux localhost 5.15.153-android13-3-28822922 #1 SMP PREEMPT Thu Feb 6 23:38:35 KST 2025 aarch64 Android
Activity
bagder commentedon Oct 17, 2026
Yeah, the DoH requests inherit a lot of options from the "mother transfer", but not the DNS settings. This is just an omission. Let me do a PR.
bagder commentedon Oct 17, 2026
@Kartatz any chance you can check if this makes things work for you?
Kartatz commentedon Oct 17, 2026
I can confirm that the PR fixes the issue for me. Thanks!
doh: inherit the CURLOPT_DNS_* options from the mother transfer