Server not available randomly in Android app

Nextcloud version: 16.0.1
Operating system and version: Debian 9.9 (NC server), Android 8.0 (client)
Apache or nginx version: Nginx 1.14.1
PHP version: 7.2.18

I’ve recently set up NC on my home server in a VM. Everything is working fine, but I have issues with DNS. I’ve set up a public cname record ( for NC that points to my dynamic IP so I can access it form the outside, and (using hairpin nat rules) from my local LAN. All is working, including desktop and mobile (Android, IOS) clients, when my is a cname record in the public DNS I manage.

The problem occurs when I add a new A record for in my Mikrotik router (which is also the DNS for my LAN) to point to my internal HAProxy service’s IP for keeping the traffic to my NC inside the lan, without hairpinning it through the router. Pretty basic infrastructure. When I add this record, the Android app just says “Server unavailable”. All desktop clients, browsers continue to work without issues. When I switch my phone to 4G to access the internet, it works again. If I remove the local A record from the router, the problem disappears on Android.

I’m not entirely sure if the issue lies with NC, the Android NC app, Android itself, or my specific DNS settings (CNAME vs A record) that’s handled wrong in Android.

Hi Kobuki,
This sounds like it’s probably a DNS issue that Andriod is having an issue with.

Of course I would first suggest checking and verifying that your andriod device has the correct DNS settings itself. Does it get DNS from DHCP on your LAN? If so are you able to check what DNS Server(s) is looking at?

From what you’re saying it sounds like perhaps it’s just not able to resolve the address correctly of your NextCloud server. You could check this by using software such as (Network Analyzer by Jiri Techet, I use this, others are available) to check DNS lookups.

Can you also confirm that DHCP is issuing out the correct DNS server address(es)?

Can you also confirm that DNS on the LAN is setup correctly for issuing out search domains?

@Scott_F, thanks for the hints. The DNS settings are fine, the DNS server is configured via DHCP on LAN clients, and it’s issuing the domain prefix, too. But, here the domain prefix is not relevant since I’m using a different, real domain, not a local one, with public DNS, LE certificate, etc. I’ve checked all this using the app you suggested (Network Analyzer).

Now, the interesting bit is when I do a DNS lookup in NA, it returns both the CNAME and the locally administered IP as well. This might confuse the Android name resolution processes. This is the only oddity I’ve found. Strangely enough Windows or Linux desktop/server clients have no problem with this, but when trying to resolve the public host address of my NC, they can resolve both the CNAME and the A record, too. They likely prioritize the A record, which is something that might be handled on the Android client, too. Or I might need to script it inside my router.

It seems I’ve found a solution, which is using ALIAS RRtype in my DNS instead of CNAME for the indirect resolution of my dynamic client IP. This effectively behaves like a single A record with a short TTL, as far as clients are concerned, avoiding the inconsistency with name resolution mentioned above. I’ll mark it as solved after a few days of proper operation.

I’ve changed the title as the old one doesn’t look relevant any more.

The issue still comes up sometimes, seemingly randomly. The only change now is the change of the IP when the phone is switching between wifi and 4G. Everything else is consistent, no cname records or weird lookup results with multiple results. It just says “Server not available”.

I can fix it by switching to 4G and then back to wifi. It’s as if the app couldn’t handle transitions between the 2 networks flawlessly every time. Restarting the app doesn’t help, only switching between networks.

Please help.

1 Like