You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IP地址变更后如何重连Cloudflare Tunnel,是否有定时重连配置参数

cloudflared客户端支持配置重连相关参数,你遇到的网络切换后隧道断开不重连问题,除了调整参数外,也和你当前使用的2021.11.0旧版本存在重连逻辑缺陷有关,建议同步升级镜像版本优化体验。

核心重连配置参数

你可以通过命令行参数或者cloudflared配置文件两种方式设置:

  • retries:连接失败后的最大重试次数,默认值为5次,设置为unlimited可开启无限重试,适配网络波动、IP变更场景
  • heartbeat-interval:云端心跳检测间隔,默认值为30s,调小可更快感知网络断开,建议设置为10s
  • heartbeat-timeout:心跳响应超时阈值,默认值为90s,超时后自动触发重连,建议对应调整为30s

调整后配置示例

docker-compose.yml

tunnel:
    image: cloudflare/cloudflared:latest # 升级到最新稳定版修复旧版本重连bug
    restart: unless-stopped # 新增自动重启策略,进程异常退出时Docker自动拉起
    command: tunnel --config /etc/cloudflared/config.yml --no-autoupdate --retries unlimited --heartbeat-interval 10s --heartbeat-timeout 30s run

cloudflared config.yml(可选,参数也可以直接写在命令行)

url: http://host.docker.internal:8000
tunnel: ***
credentials-file: /etc/cloudflared/***.json
retries: unlimited
heartbeat-interval: 10s
heartbeat-timeout: 30s

完成配置后重新启动容器即可生效,网络切换场景下cloudflared会自动尝试重新建立隧道连接,无需手动干预。

内容的提问来源于stack exchange,提问作者chriamue

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 17:15:03