Tunnel Connector Replicas, Capacity Sizing and High Availability
How cloudflared replicas work, production sizing for ports and file descriptors, scaling tunnels, and fixing capacity errors.
This page summarizes Cloudflare documentation on running Cloudflare Tunnel in production: what replicas are, how traffic is routed, how to size hosts for throughput, and how to fix the common too many open files failure.
What is a cloudflared replica?
Section titled “What is a cloudflared replica?”A tunnel is a logical object with a unique ID; each running cloudflared process is a connector. An extra connector on another host, using the same tunnel credentials, is a replica.
A replica is an additional instance of cloudflared running the same tunnel on a different host. You can create and configure a tunnel once, then run it through multiple replicas for redundancy.
— Cloudflare, Useful terms — Replica
Each running instance of cloudflared is called a connector, and it maintains several network connections to Cloudflare. A tunnel can scale beyond a single connector without changing its routes because every connector shares the same tunnel ID. Each additional connector is called a replica and usually runs on a separate host. If one connector becomes unavailable, Cloudflare can send new traffic through another.
— Cloudflare, Tunnel fundamentals
When a tunnel runs, cloudflared opens four outbound-only, post-quantum encrypted connections to at least two distinct Cloudflare data centers. A replica adds four more connections and another ingress path to your origin. You can run up to 25 replicas (100 connections) per tunnel, and traffic tends to go to the geographically closest replica. To see which replica handled a session, use Network session logs via Configuration — Replicas and high availability.
Replicas versus load balancing and multiple tunnels
Section titled “Replicas versus load balancing and multiple tunnels”What replicas are for (redundancy, not traffic steering)
Section titled “What replicas are for (redundancy, not traffic steering)”Replicas give basic redundancy: if one host fails, others keep serving. They do not provide round-robin, hash-based routing, or guaranteed session affinity on the same tunnel UUID.
Running multiple cloudflared replicas on the same tunnel UUID provides basic redundancy — if one host fails, other replicas continue serving traffic. However, the load balancer treats all replicas of the same tunnel UUID as a single endpoint.
— Cloudflare, Routing — Replicas versus load balancers
Replicas do not support traffic steering (such as round-robin or hash-based routing). When a request arrives at Cloudflare, it is forwarded to the geographically closest replica. If that connection fails, Cloudflare retries with other replicas, but there is no guarantee about which one is chosen. If you need intelligent traffic distribution, use Cloudflare Load Balancers instead.
— Cloudflare, Tunnel availability and failover
For health alerts, failover logic, or intelligent traffic steering, Cloudflare points you to Cloudflare Load Balancing rather than replicas alone—see the note under Configuration — Deploy a replica.
Session affinity with public load balancers
Section titled “Session affinity with public load balancers”If you need a client to stay on a specific host, one tunnel UUID is not enough:
The load balancer does not distinguish between replicas of the same tunnel. If you run the same tunnel UUID on two separate hosts, the load balancer treats both hosts as a single endpoint. To maintain session affinity between a client and a particular host, you will need to connect each host to Cloudflare using a different tunnel UUID.
— Cloudflare, Public load balancers — Session affinity and replicas
When to add replicas versus new tunnels
Section titled “When to add replicas versus new tunnels”| Goal | Typical approach |
|---|---|
| More availability for the same routes in one site | Add replicas on another host in the same physical location |
| More throughput to the same IP routes (ports exhausted) | Add replicas in the same location, or scale vertically on the host |
| Users or networks in different regions | Prefer separate tunnels near each region, not a distant replica |
| Blast-radius reduction for critical systems | Split routes across tunnels (e.g. private DNS on its own tunnel) |
| Port exhaustion across many large CIDRs | Split IP space across multiple tunnels, each with its own replicas |
Adding additional replicas of an existing Cloudflare Tunnel (two is the baseline recommendation) should only be done to support additional traffic to the IP routes in the tunnel. Replicas should always be added in the same physical location as one another so that they can operate in a pooled mode. If you are considering adding a replica in a different geographic location, reevaluate the network proxy design for your Cloudflare Tunnel and refer to When to add tunnels.
— Cloudflare, Tunnel capacity for cloudflared
DNS queries utilize more system resources compared to TCP and non-DNS UDP requests. To optimize service availability, Cloudflare recommends splitting private DNS traffic into its own Cloudflare Tunnel. The tunnel should run on a dedicated host and only include routes for your internal DNS resolver IPs.
— Cloudflare, System requirements — Private DNS
Useful replica scenarios from Cloudflare include extra availability points, in-network failover nodes, and updating tunnel configuration without downtime—see When to use cloudflared replicas.
How to deploy cloudflared replicas
Section titled “How to deploy cloudflared replicas”Limits per host and per tunnel
Section titled “Limits per host and per tunnel”To deploy multiple instances of cloudflared, you can create and configure one tunnel and run it on multiple hosts. If your tunnel runs as a service, only one cloudflared instance is allowed per host.
— Cloudflare, Deploy cloudflared replicas
You can run the same tunnel across various cloudflared processes for up to 100 connections (25 replicas) per tunnel. Cloudflare Load Balancers and DNS records can still point to the tunnel and its UUID. Traffic will be sent to all cloudflared processes associated with the tunnel.
— Cloudflare, Deploy cloudflared replicas
Remotely-managed tunnel (dashboard)
Section titled “Remotely-managed tunnel (dashboard)”- In the Cloudflare dashboard, open Networking > Tunnels (see Configuration — Deploy a replica and Deploy cloudflared replicas — Remotely-managed tunnels).
- Select your tunnel.
- Choose Add a replica (or Edit, then pick the target OS on the overview page, per Deploy cloudflared replicas).
- Copy the installation command and run it on the new host.
The new replica appears on the tunnel overview; all replicas share the same routes and configuration parameters (Deploy cloudflared replicas).
Locally-managed tunnel (CLI)
Section titled “Locally-managed tunnel (CLI)”On an additional host, run the same tunnel with the same credentials:
cloudflared tunnel run <NAME>See Configuration — Deploy a replica.
For Kubernetes, AWS, Azure, GCP, or Terraform, use the platform guides linked from Workers VPC tunnel configuration and Configure a tunnel — Optimize for production.
System requirements: ports, hardware, and ulimits
Section titled “System requirements: ports, hardware, and ulimits”Why ports matter more than CPU for throughput
Section titled “Why ports matter more than CPU for throughput”Unlike many legacy VPN designs where CPU and RAM dominate, Cloudflare states that tunnel throughput is mainly limited by ports configured in the OS, not raw hardware specs.
Unlike legacy VPNs where throughput is determined by the server’s memory, CPU and other hardware specifications, Cloudflare Tunnel throughput is primarily limited by the number of ports configured in system software. Therefore, when sizing your cloudflared server, the most important element is sizing the available ports on the machine to reflect the expected throughput of TCP and UDP traffic.
— Cloudflare, System requirements
Baseline production sizing
Section titled “Baseline production sizing”| Setting | Recommendation |
|---|---|
| Hosts per network location | Two dedicated hosts with a replica each |
| RAM / CPU | ≥ 4 GB RAM, ≥ 4 CPU cores per host |
Ports for cloudflared |
50,000 per host |
Open files (ulimit -n) on Linux/macOS |
≥ 70,000 |
cloudflared instances per host (service mode) |
One |
Sources: System requirements, Hardware requirements, Platform system requirements.
Cloudflare notes this baseline is often enough for on the order of 8,000 Cloudflare One Client users (about 4,000 per host) in System requirements — Recommendations, though actual load depends on RPS, bandwidth, and traffic mix.
Configure local port range (Linux)
Section titled “Configure local port range (Linux)”echo 'net.ipv4.ip_local_port_range = 11000 60999' | sudo tee -a /etc/sysctl.d/99-cloudflared.confsudo sysctl -p /etc/sysctl.d/99-cloudflared.confIf /etc/sysctl.d/ is missing, use /etc/sysctl.conf instead—see System requirements — Number of ports and Platform system requirements — Port configuration.
Configure dynamic ports (Windows)
Section titled “Configure dynamic ports (Windows)”netsh int ipv4 set dynamicport tcp start=11000 num=50000netsh int ipv4 set dynamicport udp start=11000 num=50000netsh int ipv6 set dynamicport tcp start=11000 num=50000netsh int ipv6 set dynamicport udp start=11000 num=50000Set open-file limits (Linux and macOS)
Section titled “Set open-file limits (Linux and macOS)”Check current limits:
ulimit -aFor the current shell session:
ulimit -n 70000Persist limits using your OS’s supported method—session-only changes do not survive reboot. See System requirements — ulimits.
Throughput and when you hit limits
Section titled “Throughput and when you hit limits”- TCP: ports are released quickly; overload at 50,000 available ports would require on the order of 50,001 sustained TCP requests per second (Estimated throughput).
- UDP / DNS: DNS queries can hold ports for about five seconds; private DNS at scale often needs its own tunnel on a dedicated host (Private DNS, Estimated throughput).
When a single machine runs out of ports, add another host running a replica or split traffic across tunnels (Tunnel capacity for cloudflared).
Capacity calculator and metrics
Section titled “Capacity calculator and metrics”After roughly a week of representative traffic, use tunnel metrics such as cloudflared_tcp_total_sessions and cloudflared_udp_total_sessions, plus private DNS QPS if applicable, and feed them into Cloudflare’s sizing calculator inputs (ports per host, replica count, UDP timeouts)—see Calculate your tunnel capacity and Hardware requirements — Capacity calculator. Results are estimates only.
Monitor CPU (keep average below ~70%), memory, bandwidth, and connection count; scale vertically before adding hosts when approaching limits (Hardware requirements — Scaling considerations).
Production best practices checklist
Section titled “Production best practices checklist”Cloudflare’s recurring production guidance includes:
- Run at least two replicas per tunnel for production (Tunnels for Platforms — Best practices for large deployments, Connect with Cloudflare Tunnel — Best practices).
- Segregate production and staging across different tunnels; distribute critical services (private DNS, Active Directory, and similar) across tunnels to limit blast radius (Connect with Cloudflare Tunnel — Best practices).
- Enable dashboard notifications, review health metrics, set logging levels, enforce egress-only firewall patterns, and update cloudflared regularly (Connect with Cloudflare Tunnel — Best practices, Configure a tunnel).
- At large scale: automate lifecycle with API or Terraform, reconcile unused tunnels, and avoid duplicate creates—see Tunnels for Platforms.
For an additional point of availability, add a cloudflared replica to another host machine in your network.
— Cloudflare, Best practices — Deploy another instance of cloudflared
Common mistakes
Section titled “Common mistakes”- Treating replicas as load balancers or expecting predictable replica choice (routing is closest geographic, with retries but no guarantee)—Tunnel availability, Useful terms — Replica.
- Placing a “failover” replica in a remote region instead of a local second host or a regional tunnel—Tunnel capacity — When to add replicas.
- Running multiple cloudflared services on one host (not supported)—Deploy cloudflared replicas.
- Autoscaling down replicas and dropping active sessions—Workers VPC tunnel note.
- Skipping 50,000 ports and
ulimit -n≥ 70,000, then hitting socket: too many open files—sections below and Common errors.
Troubleshooting: “socket: too many open files”
Section titled “Troubleshooting: “socket: too many open files””What the error means
Section titled “What the error means”If your Cloudflare Tunnel logs return a socket: too many open files error, it means that cloudflared has exhausted the open files limit on your machine. The maximum number of open files, or file descriptors, is an operating system setting that determines how many files a process is allowed to open. To increase the open file limit, you will need to configure ulimit settings on the machine running cloudflared.
— Cloudflare, Common errors
The same guidance appears in Troubleshooting, Cloudflare One tunnel troubleshooting, and Troubleshoot tunnels.
Fix on the cloudflared server
Section titled “Fix on the cloudflared server”- Raise persistent
ulimit -nto at least 70,000 (System requirements — ulimits). - Confirm port range configuration on Linux or Windows (Number of ports).
- If limits are correct but load remains high, add a replica host in the same location or split high-volume routes (especially DNS) onto another tunnel (Tunnel capacity).
How to check this on your site
Section titled “How to check this on your site”- In the Cloudflare dashboard, open Networking > Tunnels, select your tunnel, and confirm two or more active replicas in the overview (Deploy cloudflared replicas).
- On each
cloudflaredhost, runulimit -aand verify open files ≥ 70,000; confirm Linuxip_local_port_rangeor Windows dynamic port settings match System requirements. - Enable tunnel health alerts and review metrics (
cloudflared_tcp_total_sessions,cloudflared_udp_total_sessions) for a representative period, then compare against the inputs described in Calculate your tunnel capacity. - Inspect connector logs for
socket: too many open files; if present, apply Common errors and re-check replica count and route split for DNS-heavy traffic. - You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about, and we will correct or clarify it.