
Cloudflare Vpc Services
- 65 installs
- 14 repo stars
- Updated April 20, 2026
- nodnarbnitram/claude-code-extensions
Helps with ai & agent building tasks during AI-assisted development.
About
cloudflare-vpc-services is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.
- cloudflare-vpc-services
- AI & Agent Building
- AI-coding skill
Cloudflare Vpc Services by the numbers
- 65 all-time installs (skills.sh)
- Ranked #6,085 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/nodnarbnitram/claude-code-extensions --skill cloudflare-vpc-servicesAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 65 |
|---|---|
| repo stars | ★ 14 |
| Last updated | April 20, 2026 |
| Repository | nodnarbnitram/claude-code-extensions ↗ |
What it does
Helps with ai & agent building tasks during AI-assisted development.
Files
Cloudflare VPC Services
Enable Workers to securely access private APIs and services through encrypted tunnels without public internet exposure.
⚠️ BEFORE YOU START
This skill prevents 5 common errors and saves ~60% tokens.
| Metric | Without Skill | With Skill |
|---|---|---|
| Setup Time | 45+ min | 10 min |
| Common Errors | 5 | 0 |
| Token Usage | ~8000 | ~3000 |
Known Issues This Skill Prevents
1. dns_error from outdated cloudflared version or wrong protocol 2. Requests leaving VPC due to using public hostnames instead of internal 3. Port mismatch - fetch() port is ignored, service config port is used 4. Missing absolute URLs in fetch() calls 5. Incorrect tunnel ID or service binding configuration
Quick Start
Step 1: Verify Tunnel Requirements
# Check cloudflared version on remote infrastructure (K8s, EC2, etc.)
# Must be 2025.7.0 or later
cloudflared --version
# Verify QUIC protocol is configured (not http2)
# Check tunnel config or Cloudflare dashboardWhy this matters: Workers VPC requires cloudflared 2025.7.0+ with QUIC protocol. Older versions or http2 protocol cause dns_error.
Step 2: Create VPC Service
# Use Cloudflare API or dashboard to create VPC service
# See templates/vpc-service-ip.json or templates/vpc-service-hostname.jsonWhy this matters: The VPC service defines the actual target (IP/hostname) that the tunnel routes to. The fetch() URL only sets Host header and SNI.
Step 3: Configure Wrangler Binding
// wrangler.jsonc
{
"vpc_services": [
{
"binding": "PRIVATE_API",
"service_id": "<YOUR_SERVICE_ID>",
"remote": true
}
]
}Why this matters: The binding name becomes the environment variable used in Worker code: env.PRIVATE_API.fetch().
Critical Rules
✅ Always Do
- ✅ Use absolute URLs with protocol, host, and path in fetch()
- ✅ Use internal VPC hostnames, not public endpoints
- ✅ Ensure cloudflared is 2025.7.0+ with QUIC protocol
- ✅ Allow UDP port 7844 outbound for QUIC connections
❌ Never Do
- ❌ Use port numbers in fetch() URL (they're ignored)
- ❌ Use public hostnames for services inside VPC
- ❌ Assume http2 protocol works (only QUIC is supported)
- ❌ Use relative URLs in fetch()
Common Mistakes
❌ Wrong:
// Port is ignored, relative URL fails
const response = await env.VPC_SERVICE.fetch("/api/users:8080");✅ Correct:
// Absolute URL, port configured in VPC service
const response = await env.VPC_SERVICE.fetch("https://internal-api.company.local/api/users");Why: The VPC service configuration determines actual routing. The fetch() URL only populates the Host header and SNI value.
Known Issues Prevention
| Issue | Root Cause | Solution |
|---|---|---|
dns_error | cloudflared < 2025.7.0 or http2 protocol | Update cloudflared, configure QUIC, allow UDP 7844 |
| Requests go to public internet | Using public hostname in fetch() | Use internal VPC hostname |
| Connection refused | Wrong port in VPC service config | Configure correct http_port/https_port in service |
| Timeout | Tunnel not running or wrong tunnel_id | Verify tunnel status, check tunnel_id |
| 404 errors | Incorrect path routing | Verify internal service path matches fetch() path |
Configuration Reference
wrangler.jsonc
{
"name": "my-worker",
"main": "src/index.ts",
"compatibility_date": "2024-01-01",
"vpc_services": [
{
"binding": "PRIVATE_API",
"service_id": "daf43e8c-a81a-4242-9912-4a2ebe4fdd79",
"remote": true
},
{
"binding": "PRIVATE_DATABASE",
"service_id": "453b6067-1327-420d-89b3-2b6ad16e6551",
"remote": true
}
]
}Key settings:
binding: Environment variable name for accessing the serviceservice_id: UUID from VPC service creationremote: Must betruefor VPC services
Common Patterns
Basic GET Request
export default {
async fetch(request, env) {
const response = await env.PRIVATE_API.fetch(
"https://internal-api.company.local/users"
);
return response;
}
};POST with Authentication
const response = await env.PRIVATE_API.fetch(
"https://internal-api.company.local/users",
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${env.API_TOKEN}`
},
body: JSON.stringify({ name: "John", email: "john@example.com" })
}
);API Gateway with Path Routing
export default {
async fetch(request, env) {
const url = new URL(request.url);
if (url.pathname.startsWith('/api/users')) {
return env.USER_SERVICE.fetch(
`https://user-api.internal${url.pathname}`
);
} else if (url.pathname.startsWith('/api/orders')) {
return env.ORDER_SERVICE.fetch(
`https://orders-api.internal${url.pathname}`
);
}
return new Response('Not Found', { status: 404 });
}
};Bundled Resources
Templates
Located in templates/:
- `wrangler-vpc.jsonc` - Ready-to-use wrangler config with VPC bindings
- `vpc-service-ip.json` - IP-based VPC service API payload
- `vpc-service-hostname.json` - Hostname-based VPC service API payload
Copy these templates as starting points for your implementation.
Scripts
Located in scripts/:
- `list-vpc-services.sh` - List VPC services via Cloudflare API
- `tail-worker.sh` - Debug VPC connections with live logs
- `set-api-token.sh` - Set secrets for private API auth
References
Located in references/:
- `api-patterns.md` - Comprehensive fetch() patterns and examples
Dependencies
Required
| Package | Version | Purpose |
|---|---|---|
| wrangler | latest | Deploy Workers with VPC bindings |
| cloudflared | 2025.7.0+ | Tunnel daemon (on remote infrastructure) |
Optional
| Package | Version | Purpose |
|---|---|---|
| @cloudflare/workers-types | latest | TypeScript types for Workers |
Official Documentation
Troubleshooting
dns_error when calling VPC service
Symptoms: Worker returns dns_error when calling env.VPC_SERVICE.fetch()
Solution: 1. Update cloudflared to 2025.7.0+ on remote infrastructure 2. Configure QUIC protocol (not http2) 3. Allow UDP port 7844 outbound
Requests going to public internet
Symptoms: Logs show requests hitting public endpoints instead of internal
Solution:
// Use internal hostname
const response = await env.VPC_SERVICE.fetch(
"https://internal-api.vpc.local/endpoint" // Internal
// NOT "https://api.company.com/endpoint" // Public
);Connection timeout
Symptoms: Requests hang and eventually timeout
Solution: 1. Verify tunnel is running: check cloudflared logs 2. Verify tunnel_id matches in VPC service config 3. Check network connectivity from tunnel to target
Setup Checklist
Before using this skill, verify:
- [ ] cloudflared 2025.7.0+ deployed on remote infrastructure
- [ ] QUIC protocol configured (not http2)
- [ ] UDP port 7844 outbound allowed
- [ ] VPC service created with correct tunnel_id
- [ ] wrangler.jsonc has vpc_services binding
- [ ] Using internal hostnames (not public endpoints)
- [ ] Using absolute URLs in fetch() calls
Cloudflare VPC Services Skill
| Status | Version | Last Updated | Confidence | Production Tested |
|---|---|---|---|---|
| Active | 1.0.0 | 2024-11 | 4/5 | Internal projects |
What This Skill Does
- Diagnose
dns_errorand connectivity issues with VPC services - Create VPC service configurations (IP-based and hostname-based)
- Configure wrangler.jsonc bindings for VPC services
- Write Worker code with service binding fetch() patterns
- Troubleshoot tunnel and routing problems
Auto-Trigger Keywords
Primary Keywords
- vpc service
- cloudflared tunnel
- service binding
- private api access
- workers vpc
Secondary Keywords
- tunnel configuration
- wrangler vpc_services
- internal api
- cross-cloud connectivity
- QUIC protocol
Error Pattern Keywords
dns_error- "requests leaving vpc"
- "connection timeout vpc"
- "port ignored"
- "tunnel not connecting"
Known Issues Prevention
| Issue | Prevention |
|---|---|
| dns_error | Enforce cloudflared 2025.7.0+, QUIC protocol |
| Wrong routing | Use internal hostnames, not public |
| Port confusion | Document that fetch() port is ignored |
When to Use
Use for:
- Setting up new VPC service connections
- Debugging
dns_erroror timeout issues - Configuring wrangler for VPC bindings
- Writing Worker code that accesses private APIs
- Troubleshooting tunnel connectivity
Don't use for:
- General Cloudflare Workers development (use cloudflare-workers-expert)
- Public API integrations
- Cloudflare Access/Zero Trust setup (different use case)
Quick Usage
// Worker code with VPC service binding
export default {
async fetch(request, env) {
const response = await env.PRIVATE_API.fetch(
"https://internal-api.vpc.local/users"
);
return response;
}
};Token Efficiency
| Approach | Tokens | Time |
|---|---|---|
| Manual research + trial/error | ~8000 | 45 min |
| With this skill | ~3000 | 10 min |
| Savings | ~60% | 78% |
File Structure
cloudflare-vpc-services/
├── SKILL.md # Main instructions and patterns
├── README.md # This file (discovery/metadata)
├── templates/
│ ├── wrangler-vpc.jsonc # Ready-to-use wrangler config
│ ├── vpc-service-ip.json # IP-based service payload
│ └── vpc-service-hostname.json # Hostname-based service payload
├── scripts/
│ └── list-vpc-services.sh # List services via API
└── references/
└── api-patterns.md # Comprehensive fetch() examplesDependencies
| Package | Version | Verified |
|---|---|---|
| wrangler | latest | 2024-11 |
| cloudflared | 2025.7.0+ | 2024-11 |
Related Skills
cloudflare-workers-expert- General Workers developmentcloudflare-workflows-expert- Durable execution workflows
VPC Service API Patterns
Comprehensive fetch() patterns for Workers VPC service bindings.
Service Binding API
const response = await env.VPC_SERVICE_BINDING.fetch(resource, options);Parameters
resource(string | URL | Request): Absolute URL with protocol, host, pathoptions(optional RequestInit): Standard fetch options
Important Routing Behavior
The VPC Service configuration determines actual connectivity—not the fetch() URL:
- Host in fetch() → HTTP "Host" header and SNI value only
- Port in fetch() → IGNORED (uses configured service port)
- Actual connection → Service's configured hostname/IP and port
Basic Patterns
GET Request
export default {
async fetch(request, env) {
const response = await env.VPC_SERVICE.fetch(
"https://internal-api.company.local/users"
);
const users = await response.json();
return new Response(JSON.stringify(users), {
headers: { "Content-Type": "application/json" }
});
}
};POST with JSON Body
const response = await env.VPC_SERVICE.fetch(
"https://internal-api.company.local/users",
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${env.API_TOKEN}`
},
body: JSON.stringify({
name: "John Doe",
email: "john@example.com"
})
}
);PUT/PATCH Updates
const response = await env.VPC_SERVICE.fetch(
`https://internal-api.company.local/users/${userId}`,
{
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ status: "active" })
}
);DELETE Request
const response = await env.VPC_SERVICE.fetch(
`https://internal-api.company.local/users/${userId}`,
{ method: "DELETE" }
);Advanced Patterns
HTTPS with IP Address
// When service is configured with IP, use any hostname in URL
// The Host header will be set from the URL
const response = await env.VPC_SERVICE.fetch("https://10.0.1.50/api/data");API Gateway with Path Routing
export default {
async fetch(request, env) {
const url = new URL(request.url);
if (url.pathname.startsWith('/api/users')) {
return env.USER_SERVICE.fetch(
`https://user-api.internal${url.pathname}${url.search}`
);
} else if (url.pathname.startsWith('/api/orders')) {
return env.ORDER_SERVICE.fetch(
`https://orders-api.internal${url.pathname}${url.search}`
);
}
return new Response('Not Found', { status: 404 });
}
};Request Forwarding with Headers
export default {
async fetch(request, env) {
const url = new URL(request.url);
// Forward the request with original headers
const response = await env.VPC_SERVICE.fetch(
`https://internal-api.local${url.pathname}`,
{
method: request.method,
headers: request.headers,
body: request.body
}
);
return response;
}
};Error Handling
export default {
async fetch(request, env) {
try {
const response = await env.VPC_SERVICE.fetch(
"https://internal-api.local/data"
);
if (!response.ok) {
return new Response(`Internal API error: ${response.status}`, {
status: 502
});
}
return response;
} catch (error) {
// Handle tunnel/connectivity errors
return new Response(`VPC connection failed: ${error.message}`, {
status: 503
});
}
}
};Timeout with AbortController
export default {
async fetch(request, env) {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 5000);
try {
const response = await env.VPC_SERVICE.fetch(
"https://internal-api.local/slow-endpoint",
{ signal: controller.signal }
);
clearTimeout(timeoutId);
return response;
} catch (error) {
if (error.name === 'AbortError') {
return new Response('Request timeout', { status: 504 });
}
throw error;
}
}
};Multiple Services
export default {
async fetch(request, env) {
// Call multiple internal services
const [users, orders] = await Promise.all([
env.USER_SERVICE.fetch("https://user-api.internal/users"),
env.ORDER_SERVICE.fetch("https://orders-api.internal/orders")
]);
const userData = await users.json();
const orderData = await orders.json();
return new Response(JSON.stringify({
users: userData,
orders: orderData
}), {
headers: { "Content-Type": "application/json" }
});
}
};TypeScript Types
interface Env {
VPC_SERVICE: Fetcher;
USER_SERVICE: Fetcher;
ORDER_SERVICE: Fetcher;
API_TOKEN: string;
}
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const response = await env.VPC_SERVICE.fetch(
"https://internal-api.local/data"
);
return response;
}
};References
Deep-dive documentation and patterns for Cloudflare VPC Services.
Contents
api-patterns.md
Comprehensive fetch() patterns for VPC service bindings including:
- Basic CRUD operations
- Advanced patterns (API gateway, request forwarding)
- Error handling
- TypeScript types
- Multiple service coordination
Official Documentation
#!/bin/bash
# List VPC services for your Cloudflare account
#
# Prerequisites:
# - wrangler installed: npm install -g wrangler
# - logged in: npx wrangler login
set -e
echo "Listing VPC services..."
echo ""
npx wrangler vpc service list
Scripts
Utility scripts for working with Cloudflare VPC Services.
Prerequisites
- wrangler installed:
npm install -g wrangler - logged in:
npx wrangler login
list-vpc-services.sh
Lists all VPC services in your Cloudflare account using wrangler vpc service list.
chmod +x list-vpc-services.sh
./list-vpc-services.shtail-worker.sh
Tail logs from a deployed Worker to debug VPC connections.
./tail-worker.sh my-worker
./tail-worker.sh my-worker --errors-onlyUseful for debugging dns_error, timeouts, and routing issues.
set-api-token.sh
Set a secret for authenticating with private services.
./set-api-token.sh my-worker API_TOKEN
./set-api-token.sh my-worker PRIVATE_API_KEYThe secret will be available as env.API_TOKEN in your Worker code.
#!/bin/bash
# Set API token secret for authenticating with private services
#
# Usage: ./set-api-token.sh <worker-name> <secret-name>
set -e
WORKER_NAME="$1"
SECRET_NAME="${2:-API_TOKEN}"
if [ -z "$WORKER_NAME" ]; then
echo "Usage: ./set-api-token.sh <worker-name> [secret-name]"
echo ""
echo "Examples:"
echo " ./set-api-token.sh my-worker"
echo " ./set-api-token.sh my-worker PRIVATE_API_KEY"
exit 1
fi
echo "Setting secret '$SECRET_NAME' for worker: $WORKER_NAME"
echo "Enter the secret value (will be hidden):"
npx wrangler secret put "$SECRET_NAME" --name "$WORKER_NAME"
echo ""
echo "Secret set. Access it in your Worker as: env.$SECRET_NAME"
#!/bin/bash
# Tail logs from a deployed Worker to debug VPC service connections
#
# Usage: ./tail-worker.sh <worker-name> [--errors-only]
set -e
WORKER_NAME="$1"
FILTER=""
if [ -z "$WORKER_NAME" ]; then
echo "Usage: ./tail-worker.sh <worker-name> [--errors-only]"
echo ""
echo "Examples:"
echo " ./tail-worker.sh my-worker"
echo " ./tail-worker.sh my-worker --errors-only"
exit 1
fi
if [ "$2" = "--errors-only" ]; then
FILTER="--status error"
fi
echo "Tailing logs for worker: $WORKER_NAME"
echo "Press Ctrl+C to stop"
echo ""
npx wrangler tail "$WORKER_NAME" $FILTER --format pretty
{
"type": "http",
"host": {
"hostname": "internal-api.company.local",
"resolver_network": {
"tunnel_id": "<YOUR_TUNNEL_ID>",
"resolver_ips": ["10.0.0.1"]
}
}
}
{
"type": "http",
"ipv4": "10.0.0.1",
"http_port": 80,
"https_port": 443,
"host": {
"network": {
"tunnel_id": "<YOUR_TUNNEL_ID>"
}
}
}
{
"name": "my-worker",
"main": "src/index.ts",
"compatibility_date": "2024-01-01",
// VPC Service Bindings
// Each binding creates an env variable for accessing private services
"vpc_services": [
{
// Environment variable name: env.PRIVATE_API
"binding": "PRIVATE_API",
// UUID from VPC service creation (Cloudflare API or dashboard)
"service_id": "<YOUR_SERVICE_ID>",
// Must be true for VPC services
"remote": true
}
// Add more bindings as needed:
// {
// "binding": "PRIVATE_DATABASE",
// "service_id": "<ANOTHER_SERVICE_ID>",
// "remote": true
// }
],
// Other common settings
"vars": {
// Add any environment variables your Worker needs
// "API_TOKEN": "your-token"
}
}