Issue with Consul Connect and Proxy definition

I have a service that I want to proxy with Connect and followed what is indicated here: https://learn.hashicorp.com/tutorials/consul/get-started-service-networking

This is my “hello” service:

{
  "service": {
    "name": "node",
    "port": 3000,
    "connect": {
      "sidecar_service": {}
    }
  }
}

I then do a “consul reload” and create the proxy with “consul connect proxy -sidecar-for node &”

When I create another service like this “consul connect proxy -service web -upstream node:9191”, I can verify that I can reach my node service by calling the web service on port 9191 (curl localhost:9191). But when I define my web service in a json file as shown below, then register it (with “consul reload”) and want to connect to it, I have the following error:

curl: (7) Failed to connect to localhost port 9191: Connection refused 

web.json

{
  "service": {
    "name": "web",
    "connect": {
      "sidecar_service": {
        "proxy": {
          "upstreams": [
            {
              "destination_name": "node",
              "local_bind_port": 9191
            }
          ]
        }
      }
    }
  }
}

Is there anything I missed?

Thanks - Christian

Hi Christian. Thanks for using Consul! What version of Consul are you using? Do you have ACLs enabled, and if so, have you set your CONSUL_HTTP_TOKEN environment variable to a token that has permissions to connect? Are you able to verify there is a process is running on port 9191, and if so can you view its logs?

Thanks for reaching out. My bad, I forgot to start the web proxy service. Once started, all was fine.

1 Like