go network_error ai_generated true

rpc 错误:代码 = Unavailable 描述 = 连接错误:描述 = "传输:拨号时出错:拨号 tcp 127.0.0.1:50051:连接被拒绝"

rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing: dial tcp 127.0.0.1:50051: connect: connection refused"

ID: go/grpc-connection-refused

其他格式: JSON · Markdown 中文 · English
80%修复率
90%置信度
0证据数
2024-07-19首次发现

版本兼容性

版本状态引入弃用备注
1.7 active

根因分析

服务器未运行或端口未开放。

English

Server is not running or the port is not open.

generic

解决方案

  1. 100% 成功率
    lis, _ := net.Listen("tcp", ":50051"); s := grpc.NewServer(); pb.RegisterGreeterServer(s, &server{}); s.Serve(lis)
  2. 90% 成功率
    Ensure client dials the correct address: grpc.Dial("localhost:50051", grpc.WithInsecure())

无效尝试

常见但无效的做法:

  1. 90% 失败

    The server is not listening on any port.

  2. 50% 失败

    Firewall is not the issue if the server is not running.