Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

VPC Service and Network Bindings for Private Network Access

How edge Workers reach private APIs, databases, and mesh routes via VPC Services, VPC Networks, tunnels, and Wrangler bindings—without public exposure.

This page summarises Cloudflare Workers VPC documentation on connecting Cloudflare Workers to private APIs, databases, and internal services that are not reachable from the public internet. Connectivity runs through Cloudflare Tunnel, Cloudflare Mesh, or Cloudflare WAN on-ramps, using familiar Worker bindings and fetch() (or connect() for raw TCP on VPC Networks).

Workers VPC Services is now available, enabling your Workers to securely access resources in your private networks, without having to expose them on the public Internet.

— Cloudflare, Announcing Workers VPC Services (Beta)

Workers VPC is currently in beta: features and APIs may change before general availability, and VPC usage is free on all Workers plans during the open beta while standard Workers compute and request pricing still applies (Workers VPC pricing, platform limits).

Workers VPC: why private network access from the edge

Section titled “Workers VPC: why private network access from the edge”

Workers VPC answers the case where you want globally distributed Worker logic but backends stay in AWS, Azure, GCP, on-premise, or other private networks. Cloudflare Tunnel creates secure outbound connections from your infrastructure to Cloudflare so you do not need inbound firewall rules or public IPs on those backends.

Workers VPC allows you to connect your Workers to your private APIs, services, and databases in external clouds (AWS, Azure, GCP, on-premise, and others) that are not accessible from the public Internet.

— Cloudflare, Cloudflare Workers VPC

Two binding types cover most designs:

Feature VPC Networks VPC Services
Scope Entire tunnel or virtual network routes One registered host and port
Configuration tunnel_id, cf1:network, or cf1:vnet:<UUID> service_id
Protocols HTTP via fetch(); TCP via connect() HTTP via fetch(); TCP (e.g. with Hyperdrive)
Service registration Not required Required per target
Best when Dynamic targets, mesh/WAN, Gateway egress Fixed catalog, SSRF-scoped access

Cloudflare Tunnel: connectivity layer for Workers VPC

Section titled “Cloudflare Tunnel: connectivity layer for Workers VPC”

A tunnel is the path from Cloudflare to your private network. When you create a VPC Service, you tie it to a tunnel ID and a target host or IP; Workers VPC routes Worker traffic through that tunnel (Cloudflare Tunnel configuration for Workers VPC).

Cloudflare Tunnel creates secure connections from your infrastructure to Cloudflare’s global network, providing the network connectivity that allows Workers to access your private resources.

— Cloudflare, Cloudflare Tunnel

Roles matter: Connectivity Directory Admin is required to create VPC Services and to bind directly to a tunnel via a VPC Network binding; Connectivity Directory Bind lets you attach existing VPC Services in Workers (VPC Services required roles, Troubleshoot and debug).

cloudflared must run where it can reach your services. For Workers VPC, the tunnel should use the QUIC transport, not http2 alone—otherwise DNS resolution from Workers VPC can fail (tunnel errors).

VPC Services: bind to a specific private host or port

Section titled “VPC Services: bind to a specific private host or port”

VPC Services are entries in the connectivity directory: each one maps a Worker binding to one private target through a tunnel. They scope routing so requests go only to the intended service, which limits server-side request forgery (SSRF) risk (VPC Services).

VPC Service types: HTTP vs TCP private API access

Section titled “VPC Service types: HTTP vs TCP private API access”
  • HTTP (--type http): Workers call env.BINDING.fetch() with an absolute URL. Ports default to 80/443; you can set --http-port and/or --https-port. With https, the hostname in fetch() sets SNI.
  • TCP (--type tcp): For PostgreSQL, MySQL, and similar. Set --tcp-port and optionally --app-protocol postgresql or mysql (used by Hyperdrive private database over Workers VPC).

Critical behaviour for VPC Service bindings (Workers Binding API):

  • The VPC Service configuration always picks the connection target.
  • The host in fetch() does not route traffic; it only fills the Host header (and SNI for HTTPS).
  • The port in fetch() is ignored; configured service ports are used.

How to create a VPC Service with Wrangler CLI

Section titled “How to create a VPC Service with Wrangler CLI”

Follow Get started or the focused examples:

  1. Ensure a tunnel is running in the VPC that can reach your service (Integrations: Workers VPC).

  2. Create the service and save the returned service ID—for example a private REST API (Access a private API or website):

    npx wrangler vpc service create api-service \
    --type http \
    --tunnel-id <YOUR_TUNNEL_ID> \
    --ipv4 10.0.1.50 \
    --http-port 8080
  3. Add a vpc_services binding in Wrangler (service_id, optional remote: true for local dev) (VPC Services binding configuration).

  4. Call await env.INTERNAL_API.fetch("http://10.0.1.50:8080/api/data") in the Worker (Access a private API or website).

Other common VPC Service setups: Access a private S3 bucket, Connect to a private database, and multi-service gateways Route to private services from Workers. Manage services with Wrangler vpc service create or Terraform cloudflare_connectivity_directory_service.

Origin TLS: HTTPS and Origin CA on private origins

Section titled “Origin TLS: HTTPS and Origin CA on private origins”

For HTTPS inside the network, Workers VPC now accepts Cloudflare Origin CA certificates on private services, not only public CAs. Set --cert-verification-mode (verify_full, verify_ca, or disabled) when creating or updating a service (Get started, VPC Services).

VPC Networks: reach private IPs without per-host registration

Section titled “VPC Networks: reach private IPs without per-host registration”

VPC Network bindings grant access to anything reachable through a bound tunnel or virtual network. At runtime, the URL passed to fetch() or the address passed to connect() chooses the destination (VPC Networks).

cf1:network and cf1:vnet: virtual network selection for mesh and WAN

Section titled “cf1:network and cf1:vnet: virtual network selection for mesh and WAN”

WAN reply paths must route Cloudflare source IPs (default range 100.64.0.0/12) back through the on-ramp, or stateful flows fail (Reach Cloudflare WAN destinations from Workers VPC).

fetch() vs connect(): HTTP and raw TCP to Redis and databases

Section titled “fetch() vs connect(): HTTP and raw TCP to Redis and databases”

HTTP: env.MESH.fetch("http://10.0.1.50:8080/api/data") as in Connect Workers to Cloudflare Mesh and VPC Networks and Cloudflare Mesh support.

TCP: VPC Network bindings expose connect() for Redis, MQTT, and other non-HTTP protocols (TCP connections via connect() over VPC Networks).

connect() over VPC Networks currently supports plaintext TCP only.

— Cloudflare, TCP connections via connect() over VPC Networks

Workers Binding API: absolute URLs and routing rules

Section titled “Workers Binding API: absolute URLs and routing rules”

Both binding kinds expose fetch(resource, options) for HTTP (Workers Binding API). resource must be an absolute URL (protocol, host, path); relative paths are not supported.

When fetch() or connect() cannot connect, they throw—handle errors in Worker code and cross-check Observability for Workers VPC Services (Connections, Latency, Errors on each VPC Service Metrics tab).

Gateway egress: filter Worker outbound internet traffic

Section titled “Gateway egress: filter Worker outbound internet traffic”

With a VPC Network bound to cf1:network, calls like env.EGRESS.fetch("https://api.example.com/data") leave through Cloudflare Gateway, so Zero Trust DNS, HTTP, Network, and egress policies apply and appear in Gateway logs (Filter Workers’ public Internet traffic using Gateway policies).

Visibility. Worker egress shows up in Gateway DNS, HTTP, and Network logs alongside your other traffic, so you can audit what your Workers are calling and when.

— Cloudflare, Filter Workers’ public Internet traffic using Gateway policies

Connect Workers to Mesh best practices describe the same binding behaviour for outbound public traffic and policy enforcement.

Misrouting with public hostnames on VPC Services — If the Worker fetch() uses a public hostname that matches the VPC Service definition, traffic may leave the VPC instead of staying internal. Use internal VPC hostnames in both service config and Worker code (Troubleshoot and debug: tunnel errors).

Assuming fetch() URL overrides service config — On VPC Services, only headers/SNI follow the URL host; routing uses the registered host and ports (Workers Binding API).

Tunnel transport and DNS — ProxyError: dns_error often ties to outdated cloudflared (2025.7.0+ recommended) or http2 tunnel transport; Workers VPC needs QUIC and UDP 7844 allowed (Troubleshoot and debug).

Account caps — Up to 1000 VPC Services per account; standard Worker limits apply for request size, timeouts, and subrequests (Limits).

  1. Confirm cloudflared is healthy on a host in the private network and the tunnel UUID matches your VPC Service or Network binding (Cloudflare Tunnel).
  2. In the Workers VPC dashboard, open the VPC Service Metrics tab and verify successful connections after a test deploy (Observability for Workers VPC Services).
  3. Deploy a minimal Worker with the binding from Get started and call the private URL; on failure, note the error category (Bad Upstream, Client, Internal) in Troubleshoot and debug.
  4. If you use cf1:network egress, confirm the request appears in Cloudflare Gateway logs and matches your allow/block policies (Filter Workers’ public Internet traffic using Gateway policies).
  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

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.