title: c# Grpc Client Not able to connect to Grpc Server hosted in docker(for windows) container on localhost
body: <blockquote>
    <p>I have made a simple <code>Grpc Greeter Service</code> along with a client. When the service is hosted on localhost, client is able to call the rpc and receive the response. But when the Service is running inside docker container on localhost, the client is not able to connect to the service. </p>
  </blockquote>
  
  <p>** Grpc Service Server ** </p>
  
  <pre><code>namespace GreeterServer
  {
      class Program
      {
          private readonly static ManualResetEvent shutdown = new ManualResetEvent(false);
          static void Main(string[] args)
          {
              int port = 5000;
              Console.WriteLine("Hello World!");
              Server server = new Server{
                  Services = {GreeterService.BindService(new GreeterController())},
                  Ports = {new ServerPort("localhost", port, ServerCredentials.Insecure)}
              };
              server.Start();
              Console.WriteLine("Grpc Server started");
              Console.Read();
              shutdown.WaitOne();
          }
      }
  }
  </code></pre>
  
  <p>** Dockerfile for the Grpc Service ** </p>
  
  <pre><code>FROM microsoft/dotnet:2.1-sdk as base
  WORKDIR /app
  
  COPY *.csproj .
  RUN dotnet restore
  
  COPY . .
  RUN dotnet build -c Release -o out
  
  FROM microsoft/dotnet:2.1-runtime
  WORKDIR /app
  COPY --from=base /app/out .
  ENTRYPOINT ["dotnet", "GreeterServer.dll"]
  EXPOSE 5000
  </code></pre>
  
  <p>** Grpc Client ** </p>
  
  <pre><code>namespace GreeterClient
  {
      class Program
      {
          static void Main(string[] args)
          {
              try
              {
                  Console.WriteLine("Hello World!");
                  Channel channel = new Channel("127.0.0.1:5000", ChannelCredentials.Insecure);
                  GreeterService.GreeterServiceClient client = new GreeterService.GreeterServiceClient(channel);
                  HelloRequest request = new HelloRequest
                  {
                      Message = "Hi From Client"
                  };
                  HelloResponse response = client.SayHello(request);
                  Console.WriteLine(response.Message);
              }
              catch(Exception e)
              {
                  Console.WriteLine(e.ToString());
              }
  
          }
      }
  }
  </code></pre>
  
  <p>** Stacktrace from the Grpc Client ** </p>
  
  <pre><code>Grpc.Core.RpcException: Status(StatusCode=Unknown, Detail="Stream removed")
     at Grpc.Core.Internal.AsyncCall`2.UnaryCall(TRequest msg) in T:\src\github\grpc\src\csharp\Grpc.Core\Internal\AsyncCall.cs:line 75
     at Grpc.Core.DefaultCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request) in T:\src\github\grpc\src\csharp\Grpc.Core\DefaultCallInvoker.cs:line 46
     at Grpc.Core.Interceptors.InterceptingCallInvoker.&lt;BlockingUnaryCall&gt;b__3_0[TRequest,TResponse](TRequest req, ClientInterceptorContext`2 ctx) in T:\src\github\grpc\src\csharp\Grpc.Core\Interceptors\InterceptingCallInvoker.cs:line 51
     at Grpc.Core.ClientBase.ClientBaseConfiguration.ClientBaseConfigurationInterceptor.BlockingUnaryCall[TRequest,TResponse](TRequest request, ClientInterceptorContext`2 context, BlockingUnaryCallContinuation`2 continuation) in T:\src\github\grpc\src\csharp\Grpc.Core\ClientBase.cs:line 174
     at Grpc.Core.Interceptors.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request) in T:\src\github\grpc\src\csharp\Grpc.Core\Interceptors\InterceptingCallInvoker.cs:line 48
     at Greeter.Proto.GreeterService.GreeterServiceClient.SayHello(HelloRequest request, CallOptions options) in F:\c#\GrpcPracticeWithDocker\GreeterClient\GrpcClasses\GreeterGrpc.cs:line 70
     at Greeter.Proto.GreeterService.GreeterServiceClient.SayHello(HelloRequest request, Metadata headers, Nullable`1 deadline, CancellationToken cancellationToken) in F:\c#\GrpcPracticeWithDocker\GreeterClient\GrpcClasses\GreeterGrpc.cs:line 66
     at GreeterClient.Program.Main(String[] args) in F:\c#\GrpcPracticeWithDocker\GreeterClient\Program.cs:line 23
  </code></pre>