gRPC on localhost refuses connection when app in docker on WSL2 tries to connect to

Viewed 1073

I have wsl2 installed and docker desktop for windows on Windows 10. There is some strange behavior with gRPC server.

Each time I'm making request to my gRPC server (on WSL2) inside a docker container I got connection refused error. I can do simple checking 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 same grpc but on windows side.

Simple nodejs app 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 on windows side:

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
0 Answers
Related