From 7639381394f1dbc6365442ae9827304ad1d309c7 Mon Sep 17 00:00:00 2001 From: Roy Li Date: Wed, 10 Jan 2024 19:05:21 -0500 Subject: [PATCH] Change grpc client to dial 127.0.0.1 rather than [::] --- server/start.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server/start.go b/server/start.go index 806656906b60..58b8b9ce26d8 100644 --- a/server/start.go +++ b/server/start.go @@ -401,7 +401,16 @@ func startInProcess(parentCtx context.Context, ctx *Context, clientCtx client.Co maxRecvMsgSize = serverconfig.DefaultGRPCMaxRecvMsgSize } - grpcSrvAddrString := fmt.Sprintf("%s://%s", grpcSrvAddr.Network(), grpcSrvAddr.String()) + var grpcSrvAddrString string + if grpcSrvAddr.Network() == "tcp" { + _, port, err := net.SplitHostPort(grpcSrvAddr.String()) + if err != nil { + return err + } + grpcSrvAddrString = fmt.Sprintf("127.0.0.1:%s", port) + } else { + grpcSrvAddrString = fmt.Sprintf("%s://%s", grpcSrvAddr.Network(), grpcSrvAddr.String()) + } // If grpc is enabled, configure grpc client for grpc gateway. grpcClient, err := grpc.Dial( grpcSrvAddrString,