解决 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
触发根因
- APISIX 配置文件
config.yaml中只填写了单个 etcd 节点的 IP,该节点在维护重启或选举时导致长连接中断; - etcd 的 gRPC / HTTP 监听未开启 HTTP/2 长连接保活心跳,被底层网络防火墙在空闲时单向重置;
- 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 配置变更毫秒级在全节点内存生效。


