cloudflare / cloudflare/cloudflared

Cloudflared tunnel returns invalid responses during Home Assistant startup, breaking frontend on iOS

Open
#1,505 0 comments 1 reaction 0 assignees View on GitHub
Priority: Normal Type: Bug
Dominant language
Go
Stars
15.6k
Forks
1.4k
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.