Skip to content

Using --dns-servers + --doh-url on Android does not work #23456

Closed

Description

@Kartatz

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

  1. self-assigned this
    on Oct 17, 2026
  2. bagder commented on Oct 17, 2026

    @bagder
    Member

    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.

  3. bagder commented on Oct 17, 2026

    @bagder
    Member

    @Kartatz any chance you can check if this makes things work for you?

  4. Kartatz commented on Oct 17, 2026

    @Kartatz
    Author

    I can confirm that the PR fixes the issue for me. Thanks!

  5. added a commit that references this issue on Oct 18, 2026
    a4f76be
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions