Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# gRPC localhost - Error starting gRPC call: No such host is known

Tags:

c#

grpc

I'm trying to get Microsoft's gRPC "Greeter" application to work on my business laptop, but I keep getting the following exception when invoking the gRPC call:

Grpc.Core.RpcException: 'Status(StatusCode=Internal, Detail="Error starting gRPC call: No such host is known.")'

This is the documentation from Microsoft, which I followed. The exact code I'm running comes from Microsoft's samples and can be found on their github here.

It literally boils down to starting the most basic gRPC server and then invoking the call via

using var channel = GrpcChannel.ForAddress("https://localhost:5001");
var client =  new Greeter.GreeterClient(channel);
var reply = await client.SayHelloAsync(new HelloRequest { Name = "GreeterClient" });

The call to SayHelloAsync is the one that throws the exception. The exact same code on my home machine works fine. I've already checked my /etc/hosts file for weird entries, but nothing. I've also tried changing https://localhost:5001 to https://[::1]:5001 and https://127.0.0.1:5001, same exception, which I find incredibly weird.

I've also already tried http via AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); and calling the http endpoint, same exception.

like image 796
Jejuni Avatar asked Sep 16 '25 23:09

Jejuni


1 Answers

I figured it out. As expected it was a problem with the networking setup of my work laptop.

I had the HTTP_PROXY and HTTPS_PROXY environment variables set. These were picked up by the underlying HttpClient and tried routing the requests through the proxy. Removing the HTTP_PROXY and HTTPS_PROXY environment variables fixed the problem. Alternatively setting the NO_PROXY environment variable to localhost,127.0.0.1,::1 also fixed the problem.

like image 199
Jejuni Avatar answered Sep 19 '25 14:09

Jejuni