My tunnel keeps going down

I am running cloudflared via docker compose.

  cloudflare:
    container_name: cloudflare
    image: cloudflare/cloudflared
    restart: unless-stopped
    command: tunnel --loglevel debug run
    user: "0:0"
    environment:
      TUNNEL_TOKEN: "${CLOUDFLARE_TUNNEL}"

As soon as the container is up, I can see in the dashboard that the tunnel is Healthy.
A few seconds later it shows as Degraded. A moment later it is already Down.
And then it comes as Healthy again for a few more seconds, and so on.

I can see a bunch of “Connection terminated” in the logs.

cloudflare  | 2024-06-17T02:03:01Z DBG edge discovery: returning same edge address back to pool connIndex=3 event=0 ip=198.41.192.107
cloudflare  | 2024-06-17T02:03:01Z DBG edge discovery: returning same edge address back to pool connIndex=1 event=0 ip=198.41.200.73
cloudflare  | 2024-06-17T02:03:01Z DBG edge discovery: returning same edge address back to pool connIndex=0 event=0 ip=198.41.192.57
cloudflare  | 2024-06-17T02:03:01Z INF Registered tunnel connection connIndex=0 connection=3574a0be-c496-4d77-8ccb-a95fbd4e29da event=0 ip=198.41.192.57 location=poa02 protocol=quic
cloudflare  | 2024-06-17T02:03:01Z WRN Failed to serve quic connection error="failed to accept QUIC stream: Application error 0x0 (remote)" connIndex=3 event=0 ip=198.41.192.107
cloudflare  | 2024-06-17T02:03:01Z WRN Serve tunnel error error="failed to accept QUIC stream: Application error 0x0 (remote)" connIndex=3 event=0 ip=198.41.192.107
cloudflare  | 2024-06-17T02:03:01Z INF Retrying connection in up to 16s connIndex=3 event=0 ip=198.41.192.107
cloudflare  | 2024-06-17T02:03:01Z INF Registered tunnel connection connIndex=1 connection=8d61853e-b354-4756-8142-f21185a492ed event=0 ip=198.41.200.73 location=gru08 protocol=quic
cloudflare  | 2024-06-17T02:03:04Z DBG Current version is equal or newer than received version current_version=24 received_version=24
cloudflare  | 2024-06-17T02:03:12Z WRN Connection terminated error="failed to accept QUIC stream: Application error 0x0 (remote)" connIndex=3
cloudflare  | 2024-06-17T02:03:13Z INF Unregistered tunnel connection connIndex=1 event=0 ip=198.41.200.73
cloudflare  | 2024-06-17T02:03:13Z WRN Failed to serve quic connection error="timeout: no recent network activity" connIndex=1 event=0 ip=198.41.200.73
cloudflare  | 2024-06-17T02:03:13Z WRN Serve tunnel error error="timeout: no recent network activity" connIndex=1 event=0 ip=198.41.200.73
cloudflare  | 2024-06-17T02:03:13Z DBG edge discovery: giving new address to connection available=16 connIndex=1 event=0 ip=198.41.200.233
cloudflare  | 2024-06-17T02:03:13Z INF Retrying connection in up to 1s connIndex=1 event=0 ip=198.41.200.73
cloudflare  | 2024-06-17T02:03:13Z INF Unregistered tunnel connection connIndex=2 event=0 ip=198.41.200.193
cloudflare  | 2024-06-17T02:03:13Z WRN Failed to serve quic connection error="timeout: no recent network activity" connIndex=2 event=0 ip=198.41.200.193
cloudflare  | 2024-06-17T02:03:13Z WRN Serve tunnel error error="timeout: no recent network activity" connIndex=2 event=0 ip=198.41.200.193
cloudflare  | 2024-06-17T02:03:13Z DBG edge discovery: giving new address to connection available=16 connIndex=2 event=0 ip=198.41.200.13
cloudflare  | 2024-06-17T02:03:13Z INF Retrying connection in up to 1s connIndex=2 event=0 ip=198.41.200.193
cloudflare  | 2024-06-17T02:03:14Z INF Unregistered tunnel connection connIndex=0 event=0 ip=198.41.192.57
cloudflare  | 2024-06-17T02:03:14Z ERR Failed to serve quic connection error="timeout: no recent network activity" connIndex=0 event=0 ip=198.41.192.57
cloudflare  | 2024-06-17T02:03:14Z ERR Serve tunnel error error="timeout: no recent network activity" connIndex=0 event=0 ip=198.41.192.57
cloudflare  | 2024-06-17T02:03:14Z DBG edge discovery: giving new address to connection available=16 connIndex=0 event=0 ip=198.41.192.77
cloudflare  | 2024-06-17T02:03:14Z INF Retrying connection in up to 1s connIndex=0 event=0 ip=198.41.192.57
cloudflare  | 2024-06-17T02:03:14Z ERR Connection terminated error="timeout: no recent network activity" connIndex=1
cloudflare  | 2024-06-17T02:03:15Z ERR Connection terminated error="timeout: no recent network activity" connIndex=2
cloudflare  | 2024-06-17T02:03:16Z ERR Connection terminated error="timeout: no recent network activity" connIndex=0
cloudflare  | 2024-06-17T02:04:31Z DBG edge discovery: returning same edge address back to pool connIndex=3 event=0 ip=198.41.192.107
cloudflare  | 2024-06-17T02:04:31Z DBG edge discovery: returning same edge address back to pool connIndex=0 event=0 ip=198.41.192.77
cloudflare  | 2024-06-17T02:04:31Z DBG edge discovery: returning same edge address back to pool connIndex=2 event=0 ip=198.41.200.13
cloudflare  | 2024-06-17T02:04:31Z DBG edge discovery: returning same edge address back to pool connIndex=1 event=0 ip=198.41.200.233
cloudflare  | 2024-06-17T02:04:31Z ERR Failed to serve quic connection error="already connected to this server, trying another address" connIndex=0 event=0 ip=198.41.192.77
cloudflare  | 2024-06-17T02:04:31Z ERR Unable to establish connection. error="already connected to this server, trying another address" connIndex=0 event=0 ip=198.41.192.77
cloudflare  | 2024-06-17T02:04:31Z DBG edge discovery: giving new address to connection available=16 connIndex=0 event=0 ip=198.41.192.57
cloudflare  | 2024-06-17T02:04:31Z INF Retrying connection in up to 4s connIndex=0 event=0 ip=198.41.192.77
cloudflare  | 2024-06-17T02:04:31Z INF Registered tunnel connection connIndex=3 connection=6a23fdbf-0669-4280-adba-d137dbab9e8d event=0 ip=198.41.192.107 location=poa02 protocol=quic
cloudflare  | 2024-06-17T02:04:32Z INF Registered tunnel connection connIndex=1 connection=e4f9ae74-7650-4203-a92f-fb622c354750 event=0 ip=198.41.200.233 location=gru17 protocol=quic
cloudflare  | 2024-06-17T02:04:32Z INF Registered tunnel connection connIndex=2 connection=8ad0e27e-7ddd-4982-aa88-76319a3e3028 event=0 ip=198.41.200.13 location=gru17 protocol=quic
cloudflare  | 2024-06-17T02:04:34Z WRN Connection terminated error="already connected to this server, trying another address" connIndex=0

Looks like you have an outgoing connection problem. Can you check your firewall logs whether the tcp AND udp connection can be made or getting blocked? Keep in mind that cloudflareD is using quic to connect to Cloudflare via udp protocoll.

You should also check your outgoing docker firewall iptables rules.

Thanks for your answer.

I don’t know much about firewalls, but I think if it works at some point, there’s no reason for it to stop working after some time, right?

To provide more context, I am running cloudflared from a Raspberry Pi 4.
I followed the instructions from the link you provided, and it looks like it didn’t make much of a difference.

I am also running uptime-kuma to check for how long my tunnel’s been up, and this is how it looks like for the past 24h:

I was actually very happy yesterday in the afternoon. It was up for more than 8h straight :slight_smile:
But then this morning it’s down again.

Could this be my ISP blocking it?

Yes can be a problem. It can also be a problem of your router. Have you tried your RPI on another ones internet connection?