I'm hosting a server on my LAN with a port exposed publicly by the router. myserver.mydomain.com is pointing to the static IP of my router. So I can access the server from the the internet.

To make myserver.mydomain.com work when connected to my LAN I added an entry to the DNS server of my router, so it redirects to the private IP address of the server. This works fine for most devices connected to my LAN, except for my Android phone, where myserver.mydomain.com still resolves to the public IP of my router, even when connected to my Wi-Fi. So I suspect android always uses google DNS servers or something.

When I'm out and about connecting to some random Wi-Fi network this seems like highly desirable behavior, but when at home this creates the said issue.

I know I could configure my own DNS servers on my phone but I don’t want to configure that manually each time I connect to my LAN.

What would be the best approach here? Maybe I need to set up local access to my server differently?

  • 1
    I would suspect that its not using google DNS but rather the 4G connection. If you disable mobile data, does it still does that? Also, keep in mind that it possibly have cached the DNS locally once and that its just reusing the cached data, so you may have to clear your DNS cache too.
    – LPChip
    Jul 26, 2020 at 16:41
  • The best approach would be to have a router that supports hairpin NAT. Then you could use the public IP of the router even from within LAN. I'm not going to write an answer because the title asks about Android and DNS, and I'm not answering this.
    – Kamil Maciorowski
    Jul 26, 2020 at 17:24
  • Which Android version do you use (newer Android version ? Have you checked the DNS settings shown when you click on the Wifi network you are connected to? Usually Android uses the DNS server announced in the DHCP response received from your router unless you have enabled "Private DNS" in the network -> advanced settings (or in Firefox for Android should you use it).
    – Robert
    Jul 26, 2020 at 17:46
  • Does this answer your question? Why is Android refusing to resolve DNS records pointing to internal IP addresses? Jul 26, 2020 at 18:18
  • Most probably it's due to encrypted DNS as Robert mentioned. I've also seen users reporting this problem caused by routers advertising IPv6 DNS servers (as in the linked answer). Related: Accessing local computer using hostname, How does Android OS do DNS name resolution? Jul 26, 2020 at 18:22

1 Answer 1


Thank you all for the comments. They helped me work it out. I'm not 100% sure of the cause of the behavior. It stays even when I switch off 4G and restart the phone. In the post linked to by Irfan Latif it is suggested that Android favors IPv6 dns servers. That could be the cause since my network is IPv4 only. But the hairpin NAT provided the solution. (Called NAT Reflection in pfSense) After enabling this, things started to work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .