Description
What version of gRPC are you using?
1.71.1
What version of Go are you using (go version
)?
1.24.2 Darwin/arm64
What operating system (Linux, Windows, …) and version?
Mac m1 Sequoia 15.5
What did you do?
This is a follow up of #7429 (comment)
Essentially tried running:
https://github.com/grpc/grpc-go/blob/master/examples/helloworld/greeter_client/main.go
But got:
rpc error: code = DeadlineExceeded desc= context deadline exceeded
This was with
localhost:4317
It worked fine with
127.0.01:4317
What did you expect to see?
I expected both localhost and 127.0.01 to work.
What did you see instead?
Only 127.0.0.1 worked
I had to remove the two DNS nameservers entries on my machine to get localhost to work. But this is not an appropriate fix because I needed root to do this and breaks other functionality that does need it.
I could have also
used passthrough://localhost:4317, but for some libraries such as OTEL exporters that use grpc it is currently not possible to pass through the scheme.
I tried net.DefaultResolver.LookupIP(ctx, 'ip', 'localhost') and it resolved with no issues quickly.
The issue seems to be that grpc DNS resolver is trying to contact the name servers even for simple /etc/hosts entries that net.DefaultResolver has no issues working with.