Connection to HA locally & remotely behaves weirdly with phone VPN on or off

Hi All! I have HA running on a Raspberry Pi 4. I can access it on my local network through the usual http://homeassistant.local:8123 (for simplicity below, “HA:8123”), and I set up DuckDNS/LetsEncrypt/NGINX + open port to use it externally (remote.org below).

I noticed a weird behavior recently, where when I try to connect through my phone with our without VPN (Google One):

VPN ON VPN OFF
local network + HA:8123 err1 ok
local network + remote.org ok ok
remote + remote.org via browser ok err2
remote + remote.org via app ok err3

With:

  • err1 = ERR_NAME_NOT_RESOLVED
  • err2 = HA page, “Loading data” spins without ever loading, eventually “Unable to connect to Home Assistant”.
  • err3 = “Unable to connect to HA”. Wait → spinning wheel, then “Unable…”. “Refresh external URL” → same thing.

I don’t quite understand what’s going on… Any idea?

Details

configuration.yaml

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.30.33.0/24
  ip_ban_enabled: true
  login_attempts_threshold: 5

I haven’t found any ip_bans.yaml around…

Thanks!

Yup.
err1 is because you are connected to the vpn and homeassistant.local requires mDNS to resolve. mDNS won’t propagate to the VPN connection, so the lookup will fail. If you try and access it with the actual IP address while connected to the VPN it will probably succeed.

err2 is caused because the web app has a service worker and makes extensive use of browser caching. You will probably find that if you opened an incognito / private browsing window in whatever browser you are using, and enter the remote URL - it will load without problems.

Thanks for the reply.
Actually I amended my original post (table, last line) because after clearing app cache, I can’t connect to it remotely when the VPN is on.

For err1: you’re right, using the direct IP worked, thanks! I’ll use it instead of HA:8123 in the app so I can stay on the VPN if needed.

For err2: I tried in Incognito (using Chrome for Android), and it’s weird: the page wouldn’t load at first (ERR_TIMED_OUT), but then as I was writing this the login page appeared. I entered credentials, but then I got the “Unable to connect to HA, Retrying in x seconds” message… Then my IP got banned, I removed it from ip_bans.yaml, and back to not loading timed out.