NxValue Stack

Android Private DNS: How to Set It Up and Fix "Couldn't Connect" Errors

Android has a built-in way to encrypt the DNS lookups from every app on your phone, on Wi-Fi and mobile data alike. It's called Private DNS, and it works without installing anything. It is also one of the most confusing settings on the phone, because when something is wrong it says only "Couldn't connect", and then your internet stops.

This guide explains what Private DNS actually does, how to set it up with your own DNS hostname, and, most usefully, how to work out why it fails, step by step, in the order that finds the cause fastest.

What Private DNS is, and what it isn't

Every app on your phone starts connections with a DNS lookup: "what is the address of this name?" Normally those lookups travel unencrypted, so your Wi-Fi operator, mobile carrier, or ISP can read them. Private DNS wraps them in encryption, using DNS over TLS (DoT) on port 853. It has been available since Android 9.

What it does:

What it doesn't do:

The three modes

You'll find the setting by searching for "Private DNS" in Settings. The menu path varies by manufacturer, for example Network & internet → Private DNS on many phones, or Connections → More connection settings → Private DNS on Samsung. It has three options:

Mode What it does Watch out for
Off Uses whatever plain DNS the network provides. Nothing is encrypted.
Automatic Tries DoT on port 853 to the network's own DNS server, and falls back to plain DNS if that doesn't work. It uses the network's DNS, not yours. The silent fallback means you may not be encrypted at all.
Private DNS provider hostname Always uses the hostname you enter, over DoT, and checks the server's certificate. If it can't connect, there is no fallback: DNS stops and the internet appears dead.

To use your own DNS server, such as a private Pi-hole or AdGuard Home node, you need the third option. It is also the one that produces the "Couldn't connect" error, because it's the only mode that refuses to fall back.

One more detail: on Android 11 and later, picking some well-known providers, such as Google's dns.google or Cloudflare's one.one.one.one, reportedly makes Android use DNS over HTTP/3 instead of DoT. Google hasn't published exactly which providers that applies to. A custom hostname of your own uses DoT on port 853, which is what the rest of this guide assumes.

What a hostname needs to work

When you tap Save, Android tries to open a TLS connection to port 853 on that hostname and checks the server's certificate against the name you typed. Every one of these must be true:

  1. You entered a hostname, not an IP address. The field takes a name like dns.example.com. It has no field for a port or a URL, and DoT always uses port 853.
  2. The hostname resolves. Android first has to look the name up using the network's own DNS, before any encryption starts.
  3. The server listens for DoT on port 853, and nothing between your phone and the server blocks that port.
  4. The server presents a valid certificate for exactly that hostname, issued by a certificate authority Android trusts, not expired, and with the complete chain.

If any of the four fails, you get "Couldn't connect". The rest of this guide is a way to find which one.

How to set it up

  1. Get your DoT hostname from your DNS provider or your own server.
  2. Open Settings and search for Private DNS.
  3. Choose Private DNS provider hostname.
  4. Type the hostname exactly, with no https://, no port, and no trailing spaces.
  5. Tap Save.

If the settings screen now shows your hostname with no error, Android has validated the server. If it shows "Couldn't connect", go to the fix section below.

Check that it's really being used. Browse for a minute, then look at your DNS server's query log or dashboard. Your phone's lookups should appear there. If you use a blocking server, blocked ads and trackers should show up as blocked. A matching log is better proof than a green setting.

Fix: "Couldn't connect"

Two things to know first. In hostname mode Android deliberately does not fall back to plain DNS when the server can't be reached, which is why the whole internet stops. And the error message gives no reason, so you have to test for it.

Step 1: Get back online

Set Private DNS to Automatic (or Off). Your internet returns immediately. This is a temporary measure: you're unencrypted until the problem is fixed, but you can now test properly.

Step 2: Check the hostname itself

Most failures are small:

Step 3: Test on another network

This one test splits the problem in half. Try the same hostname on mobile data and on Wi-Fi.

Result Likely cause
Works on mobile data, fails on one Wi-Fi network That network blocks port 853: a router setting, school, office, hotel, or café network
Works on Wi-Fi, fails on mobile data Your mobile carrier blocks port 853
Fails everywhere The problem is the hostname, the server, or its certificate
Works on a different phone with the same hostname The problem is specific to your phone: its clock, its VPN, or an old certificate store

Step 4: Test the server from a computer

If it fails everywhere, check the server directly. The kdig tool (part of knot-dnsutils) makes a real DoT query and verifies the certificate the way a phone does:

kdig @dns.example.com +tls-ca +tls-hostname=dns.example.com example.com

If this fails or reports a certificate error, you have found your problem, and it is on the server. Then inspect the certificate:

openssl s_client -connect dns.example.com:853 -servername dns.example.com </dev/null

Look for these in the output:

Step 5: Certificate problems that only affect your phone

If the certificate checks out on your computer but your phone still fails:

Step 6: Network blocks and captive portals

Step 7: VPNs and other DNS apps

VPN apps, ad-blocking apps, and DNS changers can interfere. Depending on the app and the Android version, they may use their own DNS, block port 853, or ignore the Private DNS setting. If the error only appears while such an app is running, turn it off and retest, then check whether it has its own DNS or Private DNS option. Occasionally the "Couldn't connect" label has also been reported to appear even though lookups work, which is another reason to judge by whether the internet actually works and what your server's log shows.

Step 8: If you run the server yourself

Check, in this order: the DoT service is running; port 853/TCP is open in the firewall and forwarded correctly; the hostname's DNS records point at the right address (and if it has an IPv6 record, the server must also listen on IPv6, since a broken one can cause failures on IPv6 networks); the certificate hasn't expired and renewal actually reloads the service.

Quick reference

Symptom Likely cause What to do
Fails immediately on save, on every network Hostname typo, or the server or certificate is wrong Re-enter it, then test with kdig and openssl
Works on mobile data, fails on one Wi-Fi That network blocks port 853 Use Automatic on that network
Worked for weeks, then stopped everywhere Expired certificate, or the server is down Check certificate dates and the server
Fails on public Wi-Fi until you open a login page Captive portal Set Automatic, log in, switch back
Fails only with a VPN or filter app running App conflict Turn it off and retest
Fails only on one old phone Outdated trusted-certificate list, or wrong clock Fix the date and time, update Android

If port 853 is blocked and you can't change it

Android's Private DNS can't switch to another port or protocol for a custom hostname, so on a network that blocks 853 you have three realistic options:

Things that surprise people

Where NxValue fits

Every NxValue Stack node comes with its own DoT endpoint , so setup is just..paste it into Private DNS provider hostname and save. Because the node is yours, your lookups go to a private Pi-hole or AdGuard Home instance with an Unbound resolver, and your dashboard shows the blocked queries live, which is the quickest way to confirm your phone is really using it.

Most of the causes in the fix section, such as certificates, port 853, and the DoT service itself, are server-side, and those are ours to keep working. The network-side causes are not: a Wi-Fi network that blocks port 853, a captive portal, or a VPN app conflict will affect any Private DNS provider, NxValue included, and the steps above apply equally.

One practical tip: if you delete a node, your phone will keep trying its hostname and show "Couldn't connect". Switch Private DNS back to Automatic or Off first.

To see how it works before deploying, try the demo node, use the DNS Tester to check whether a resolver supports DoT and DoH, and use the DNS Setup tool for configuration on Android, iOS, Windows, and more.

Summary

Android and Pixel are trademarks of Google LLC. Pi-hole is a registered trademark of Pi-hole LLC. AdGuard Home and AdGuard for Android are trademarks of AdGuard Software Limited. Samsung is a trademark of Samsung Electronics Co., Ltd. NxValue Stack is an independent service provider and is not affiliated with any of these organizations.

Further reading

Skip the setup

Get your own private DNS Node with Unbound + AdGuard Home / Pi-hole with DoH and DoT endpoints.