Zero Trust tunnel is working with the Windows version but not with the Docker image

Hello. I set up a tunnel and installed cloudflared with the windows installer. Everything works fine, but I need to automate the the setup process with Docker. I just followed the instructions. I tried to run the docker image in 2 different ways, but none worked. The status of the tunnel is healthy, but it gives a 502 Bad Getaway error:
error="Unable to reach the origin service. The service may be down or it may not be responding to traffic from cloudflared: dial tcp 127.0.0.1:4200: connect: connection refused" connIndex=1 event=1 ingressRule=0 originService=http://localhost:4200
error="Unable to reach the origin service. The service may be down or it may not be responding to traffic from cloudflared: dial tcp 127.0.0.1:4200: connect: connection refused" connIndex=1 event=1 ingressRule=0 originService=http://localhost:4200
This is how I tried to run the cloudflared image
1. docker run cloudflare/cloudflared:latest tunnel --no-autoupdate run --token my_token

2. docker run --net=host cloudflare/cloudflared:latest tunnel --no-autoupdate run --token my_token
1. docker run cloudflare/cloudflared:latest tunnel --no-autoupdate run --token my_token

2. docker run --net=host cloudflare/cloudflared:latest tunnel --no-autoupdate run --token my_token
By running it the following way:
docker run --net=host -e TUNNEL_URL=http://0.0.0.0:8000 cloudflare/cloudflared:latest tunnel --no-autoupdate run --token my_token
docker run --net=host -e TUNNEL_URL=http://0.0.0.0:8000 cloudflare/cloudflared:latest tunnel --no-autoupdate run --token my_token
The error is a bit different when trying to reach the domain:
Unable to reach the origin service. The service may be down or it may not be responding to traffic from cloudflared: dial tcp [::1]:4200: connect: connection refused" connIndex=1 event=1 ingressRule=0 originService=http://localhost:4200
Unable to reach the origin service. The service may be down or it may not be responding to traffic from cloudflared: dial tcp [::1]:4200: connect: connection refused" connIndex=1 event=1 ingressRule=0 originService=http://localhost:4200
It looks like the docker image does not see the localhost, even if I used the --net=host flag
1 Reply
Cyb3r-Jak3
Cyb3r-Jak38mo ago
You’d be correct with docker image not seeing localhost. Localhost for docker refers to the container itself and not the host machine.

Did you find this page helpful?