Cloudflare argo tunnel gives bad gateway error

502 errors are outlined at Community Tip - Fixing Error 502 / 504: Bad Gateway and due to either CF edge or origin. For Cloudflare Tunnel 502, usually happen when cloudflared daemon is down or unresponsive to CF edge server connections.

Make sure you read documentation at Cloudflare Tunnel · Cloudflare Zero Trust docs and:

  1. Cloudflared daemon on your origin server is running properly and persists i.e. cloudflared daemon service install and configuration https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/run-tunnel/run-as-service
  2. you have properly configured your server’s local firewall’s outbound rules as per instructions at Tunnels · Cloudflare Zero Trust docs

What are the ports and IPs used by cloudflared ?

Users can implement a positive security model with Cloudflare Tunnel by restricting traffic originating from cloudflared. The parameters below can be configured for egress traffic inside of a firewall.

Edge connections

API requests

Below the output of dig commands towards the above hostnames:

$ dig region1.argotunnel.com
...

;; ANSWER SECTION:
region1.argotunnel.com. 86400   IN  A   198.41.192.7
region1.argotunnel.com. 86400   IN  A   198.41.192.47
region1.argotunnel.com. 86400   IN  A   198.41.192.107
region1.argotunnel.com. 86400   IN  A   198.41.192.167
region1.argotunnel.com. 86400   IN  A   198.41.192.227

...

$ dig region2.argotunnel.com

...

;; ANSWER SECTION:
region2.argotunnel.com. 300 IN  A   198.41.200.193
region2.argotunnel.com. 300 IN  A   198.41.200.233
region2.argotunnel.com. 300 IN  A   198.41.200.13
region2.argotunnel.com. 300 IN  A   198.41.200.53
region2.argotunnel.com. 300 IN  A   198.41.200.113

...

$ dig api.cloudflare.com

...

;; ANSWER SECTION:
api.cloudflare.com.     41      IN      A       104.19.193.29
api.cloudflare.com.     41      IN      A       104.19.192.29

...
  • These IP addresses are unlikely to change but in the event that they do, Cloudflare will update the information here.