nandakumar_r
nandakumar_r

Reputation: 13

I tried to deploy gRPC (go) server in docker and expose port in local port but port bindings are not working

I tried to deploy gRPC server and mongodb in docker. After that I trying to binding docker ports to my local ports. mongodb ports binding was working fine. But, gRPC server ports are not binding my local port

ports:
  - "50051:50051"

like this i tried in docker-compose.yml

docker-compose.yml

services:
  auth_server:
    container_name: auth_service
    build: .
    command: go run server.go
    volumes:
      - .:/go/src/auth_server
    working_dir: /go/src/auth_server
    ports:
      - "50051:50051"
    environment:
      PORT: 50051

In client gRPC file I used host and port like, 0.0.0.0:50051

conn, err := grpc.Dial("0.0.0.0:50051", grpc.WithInsecure())

but it was not working. I can't find any bug, so I assume I am doing something incorrectly.

Upvotes: 1

Views: 7268

Answers (2)

Giuseppe Corbelli
Giuseppe Corbelli

Reputation: 158

If you're running this on windows I would check the "reserved port ranges" with command

 netsh interface ipv4 show excludedportrange protocol=tcp

Also see this thread on github.

If it's linux check that nothing on the host is binding on that port.

Upvotes: 0

Alex Pliutau
Alex Pliutau

Reputation: 21957

You should use 127.0.0.1:50051 when connecting from a client on the host machine, or auth_server:50051 if you are connecting from docker-compose network.

Upvotes: 2

Related Questions