Adding a sidecar to an app ruins Consul connectivity

I have an app that used to just run one machine with no added sidecars. It used Consul for LiteFS. When I tried to add a sidecar, I noticed that the machine would not start due to the following log:

ord [info]level=INFO msg=“cannot fetch cluster ID from “consul” lease, retrying: Get “http://127.0.0.1:8500/v1/kv/litefs/[app]/clusterid\”: dial tcp 127.0.0.1:8500: connect: connection refused”

I’ve tried to do the normal fly consul detach then fly consul attach with no luck. I recovered by deleting the machine, retattaching consul, then deploying again to get a fresh machine. Then it worked normally.

So I detached consul, deleted the old machine, attached consul, then recreated the machine again and now I have a valid URL.

I think when I ran with a sidecar (was trying to run cloudflared along my app) it ended up disconnecting from Consul. I tried again in isolation and found that if I added a sidecar, it would ruin consul.

Example:

[containers]
  tunnel = { image = "cloudflare/cloudflared:latest", cmd = ["tunnel", "--no-autoupdate", "run"], secret_env = ["TUNNEL_TOKEN"] }

I used the cli-config.json method too, and that didn’t work.