cloudflared: Cloudflared hangs after internet connection severed

I am running cloudflared on ubuntu arm (raspberry pi) as a proxy dns. Whenever i restarted my router, cloudflared hangs and stops working and cant connect until i restarted the cloudflared process. Here is my cloudflared command:

cloudflared proxy-dns --port 5053 --upstream https://94.140.14.14/dns-query

Any idea of how to make cloudflared process restarts automatically if connection is lost and restored? Sorry if this has been discussed before. Thanks.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 9
  • Comments: 37 (3 by maintainers)

Most upvoted comments

Having same problem with Unifi and backup LTE connection, if it switches to backup connection and a different external IP then cloudflared hangs. Running latest editions of Pi-Hole, Cloudflared and Raspberry PI OS.

I am experiencing the same problem with cloudflared tunnel connections. If network is unavailable for a short amount of time the cloudflared service stucks after the defined --retries (default 5) value. As the time between retries increases exponentially it isn’t really helpful to increase retries. Wouldn’t it be possible to add an option to define the wait-between-retries time to allow the network to reconnect again or to kill the service so it can be brought up again by e.g. systemd or Docker?

Better idea - use dnscrypt. Problem solved.

No one at CF cares about this issue that’s been ongoing for years now. It won’t be fixed anytime soon.

https://github.com/DNSCrypt/dnscrypt-proxy

Now I can rest assured that momentary internet drops won’t end up in much longer outages.

Also exists on 2021.4.0. Any loss of, or failover of, the WAN and Cloudflared just hangs until manually restarted…

Apr 19 14:05:51 PiHole cloudflared[1306]: 2021-04-19T13:05:51Z ERR failed to connect to an HTTPS backend "https://1.1.1.1/dns-query" error="failed to perform an HTTPS request: Post \"https://1.1.1.1/dns-query\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)"
Apr 19 14:05:56 PiHole cloudflared[1306]: 2021-04-19T13:05:56Z ERR failed to connect to an HTTPS backend "https://1.1.1.1/dns-query" error="failed to perform an HTTPS request: Post \"https://1.1.1.1/dns-query\": net/http: request canceled (Client.Timeout exceeded while awaiting headers)"
Apr 19 14:06:42 PiHole cloudflared[1306]: 2021-04-19T13:06:42Z ERR failed to connect to an HTTPS backend "https://1.1.1.1/dns-query" error="failed to perform an HTTPS request: Post \"https://1.1.1.1/dns-query\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)"
Apr 19 14:06:47 PiHole cloudflared[1306]: 2021-04-19T13:06:47Z ERR failed to connect to an HTTPS backend "https://1.1.1.1/dns-query" error="failed to perform an HTTPS request: Post \"https://1.1.1.1/dns-query\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)"
Apr 19 14:08:24 PiHole cloudflared[1306]: 2021-04-19T13:08:24Z ERR failed to connect to an HTTPS backend "https://1.1.1.1/dns-query" error="failed to perform an HTTPS request: Post \"https://1.1.1.1/dns-query\": net/http: request canceled (Client.Timeout exceeded while awaiting headers)"
Apr 19 14:08:29 PiHole cloudflared[1306]: 2021-04-19T13:08:29Z ERR failed to connect to an HTTPS backend "https://1.1.1.1/dns-query" error="failed to perform an HTTPS request: Post \"https://1.1.1.1/dns-query\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)"

This makes Cloudflared completely unusable for me tbh.