W
W
wdcloud2020-06-29 17:30:11
linux
wdcloud, 2020-06-29 17:30:11

Why is gRPC on localhost rejecting the connection when a docker app on WSL2 tries to connect?

I have wsl2 installed and docker desktop for windows on windows 10. Weird behavior is happening with the gRPC server.

Every time I make a request to my gRPC server (on WSL2) inside the docker container I get a connection refused error. I can do a simple check like this:

curl -v host.docker.internal:50051
* Trying 192.168.65.2:50051...
* connect to 192.168.65.2 port 50051 failed: Connection refused
* Failed to connect to host.docker.internal port 50051: Connection refused
* Closing connection 0
curl: (7) Failed to connect to host.docker.internal port 50051: Connection refused
Any other non-grpc app works fine! Or even the same grpc but on windows side.

Simple nodejs application on WSL2:

curl -v host.docker.internal:3000
* Trying 192.168.65.2:3000...
* Connected to host.docker.internal (192.168.65.2) port 3000 (#0)
> GET / HTTP/ 1.1
> Host: host.docker.internal:3000
> User-Agent: curl/7.69.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Mon, 29 Jun 2020 10 :22:15 GMT
< Connection: keep-alive
< Transfer-Encoding: chunked
<
* Connection #0 to host host.docker.internal left intact
Hello, World!

Grpc server if running on windows responds:

curl -v host.docker.internal:50051
* Trying 192.168.65.2:50051...
* TCP_NODELAY set
* Connected to host.docker.internal (192.168.65.2) port 50051 (#0)
> GET / HTTP/1.1
> Host: host.docker.internal:50051
> User-Agent: curl/7.66.0
> Accept : */*
>
* Received HTTP/0.9 when not allowed

* Closing connection 0
curl: (1) Received HTTP/0.9 when not

allowed

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question