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

Prysm Beacon Node无法连接Geth执行节点问题排查请求

问题排查与解决

环境信息

  • 操作系统:ubuntu_18_04_64
  • Docker版本:Docker version 19.03.2, build 6a30dfc
  • Prysm镜像:prysmaticlabs/prysm-beacon-chain:latest
  • Geth镜像:ethereum/client-go:latest

容器配置

  • 两个容器运行于同一机器
  • Prysm Beacon Node启动命令:
docker run -d -v /mnt/prysm:/data -p 4000:4000 -p 13000:13000 -p 12000:12000/udp --name beacon-node prysmaticlabs/prysm-beacon-chain --datadir=/data --jwt-secret=/data/jwtsecret --execution-endpoint=http://localhost:8551  --accept-terms-of-use=true;
  • Geth节点启动命令:
docker run -d --name ethereum --restart always \
-p 8545:8545 -p 30303:30303 -p 8546:8546 -p 8551:8551 \
-v /mnt/blockchain_data/eth:/root/.ethereum ethereum/client-go \
--http --http.addr "0.0.0.0" --http.port 8545 --http.api "eth,personal,net,web3,db,txpool,ws" \
--ws --ws.addr "0.0.0.0" --ws.origins "*" --ws.port "8546" \
--authrpc.jwtsecret "/root/.ethereum/geth/jwtsecret" \
--syncmode=snap --cache=1024 --maxpeers=50

配置说明

  • 两个节点均配置JWT
  • 已映射Geth节点的8551端口到宿主机
  • 宿主机上通过nc -z -v localhost 8551测试,连接成功

问题现象

启动容器后,Prysm Beacon Node日志报错:

time="2022-09-16 05:38:19" level=error msg="无法连接到执行客户端端点" error="Post \"http://localhost:8551\": dial tcp 127.0.0.1:8551: connect: connection refused: Post \"http://localhost:8551\": dial tcp 127.0.0.1:8551: connect: connection refused" prefix=powchain;

解决方案

1. 修正执行端点地址

Docker容器内的localhost指向容器自身,而非宿主机。要让Prysm访问Geth,有两种可行方式:

  • 用容器名访问:Docker默认会为本地容器创建内部网络,直接使用Geth的容器名ethereum作为地址,将Prysm的--execution-endpoint参数改为http://ethereum:8551。
  • 用宿主机内网IP访问:查询宿主机的内网IP(比如192.168.1.100),将执行端点改为http://192.168.1.100:8551。

修改后的Prysm启动命令(容器名方式):

docker run -d -v /mnt/prysm:/data -p 4000:4000 -p 13000:13000 -p 12000:12000/udp --name beacon-node prysmaticlabs/prysm-beacon-chain --datadir=/data --jwt-secret=/data/jwtsecret --execution-endpoint=http://ethereum:8551  --accept-terms-of-use=true;

2. 确保JWT密钥完全一致

当前两个容器使用的JWT密钥文件路径不同,容易出现密钥不一致的情况:

  • Geth的密钥路径:/root/.ethereum/geth/jwtsecret
  • Prysm的密钥路径:/data/jwtsecret

需要将同一个密钥文件挂载到两个容器中,执行以下命令复制密钥:

cp /mnt/blockchain_data/eth/geth/jwtsecret /mnt/prysm/jwtsecret

完成以上修改后,重启两个容器即可解决连接问题。


内容的提问来源于stack exchange,提问作者Mr.Patience

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 21:15:39