DEBUG.WIKI
阿里云;从建站到云上业务;云服务器 · 数据库 · 对象存储;查看产品 →
PanstarCloud:部署应用,接入 AI,云服务器与 AI 网关
IPPeak:从目标地区访问网页,住宅代理、SEO 监测、广告验证

解决 Apache APISIX 报错 failed to sync with etcd: connection reset 控制面断连修复

排查 APISIX 数据面 Worker 日志密集报错 failed to sync with etcd: connection reset by peer 或 watch stream closed,分析 控制面 etcd 集群高可用连接池。

问题现象

APISIX 节点无法实时感知新配置变更,error.log 持续输出同步错误:

2026-11-16T17:15:01 [error] 18420#18420: *9210 [lua] etcd.lua:412: sync(): failed to fetch data from etcd: connection reset by peer, context: ngx.timer

触发根因

  1. APISIX 配置文件 config.yaml 中只填写了单个 etcd 节点的 IP,该节点在维护重启或选举时导致长连接中断;
  2. etcd 的 gRPC / HTTP 监听未开启 HTTP/2 长连接保活心跳,被底层网络防火墙在空闲时单向重置;
  3. APISIX Worker 内存中配置的版本号(Revision)与 etcd 发生脱节。

解决步骤

在 config.yaml 中配置多节点冗余的高可用 etcd 列表

提供全量对等端点支持自动故障转移:

etcd:
  host:
    - "http://10.0.1.10:2379"
    - "http://10.0.1.20:2379"
    - "http://10.0.1.30:2379"
  prefix: "/apisix"
  timeout: 30
  resync_delay: 5

调整 etcd 端的心跳保活参数

避免长连接被防火墙误杀:

etcd:
  keepalive_time: 30
  keepalive_timeout: 10

验证确认

重载 APISIX 进程:

apisix reload

Watch 监听流成功建立长效监听,etcd 配置变更毫秒级在全节点内存生效。