Cloudflared tunnel returns invalid responses during Home Assistant startup, breaking frontend on iOS
Hi,
I’d like to report a problem I’ve observed when using cloudflared to expose a Home Assistant instance via a secure tunnel.
When Home Assistant is restarting, and I open the iOS Companion App (which uses the external Cloudflare domain), the frontend fails to load correctly: • Most dashboard cards show “configuration errors” (especially ones that rely on external JS files like custom cards). • The issue persists until I manually reset the frontend cache on iOS. • The issue is 100% reproducible when launching the iOS app during HA startup via the Cloudflared tunnel.
• If I connect to Home Assistant via local IP (http://192.168.x.x:8123), the problem does not occur, even if the app is opened during HA boot.
• Logs indicate that Cloudflared is returning 502 Bad Gateway or possibly empty responses during early HA startup.
• This causes iOS WKWebView to cache invalid JS, which the app never recovers from, even once HA is ready.
• Browsers like Chrome or Safari handle this gracefully, but iOS doesn’t.
Configuring the Companion App with: • Internal URL: http://192.168.x.x:8123 • External URL: https://my-ha.cloudflare.com
…resolves the issue completely when at home.
🙏 Request
Would it be possible to: • Improve the retry behavior of Cloudflared during early startup? • Delay responding with 502s until a proper backend response is available? • Or offer a configuration option to delay tunnel availability until the local server is fully ready?
Let me know if more logs or trace output are needed.