OpenAICloudflare Developer PlatformJun 16, 2026, 12:00 AM

Workers VPC - TCP connections via connect() over VPC Networks

A condensed section focused on the key takeaways first.

Original Post

Quick Digest

Summary

A condensed section focused on the key takeaways first.

openaienmodel: gpt-5-mini-2025-08-07

Workers VPC - TCP connections via connect() over VPC Networks

Key Points

  • connect() enables raw TCP to private services
  • Works via Tunnel, Mesh, or WAN on‑ramp
  • Plaintext TCP only (no TLS)

Summary

Cloudflare Workers VPC Network bindings now support the Socket API connect() to open raw TCP connections to private destinations reachable through a bound Cloudflare Tunnel, Cloudflare Mesh, or Cloudflare WAN on‑ramp. This enables Workers to speak directly to services like Redis, Memcached, MQTT, or any custom TCP protocol over the private network.

Key Points

  • Configure a VPC network binding in wrangler (JSONC or TOML) and set remote: true to enable private connectivity.
  • At runtime call connect() on the binding (e.g., env.PRIVATE_NETWORK.connect("10.0.1.50:6379")) to obtain a readable/writable socket.
  • Example (TypeScript):
const socket = await env.PRIVATE_NETWORK.connect("10.0.1.50:6379");
const writer = socket.writable.getWriter();
await writer.write(new TextEncoder().encode("PING \r\n"));
await writer.close();
return new Response(socket.readable);
  • Supported transports: plaintext TCP only (no TLS termination via connect()).
  • Works for any TCP-based private service reachable via the bound Tunnel/Mesh/WAN on‑ramp.
  • See VPC Networks and Workers Binding API docs for details and security considerations.

Configuration example

JSONC

{
  "$schema": "./node_modules/wrangler/config-schema.json",
  "vpc_networks": [
    { "binding": "PRIVATE_NETWORK", "network_id": "cf1:network", "remote": true }
  ]
}

TOML

[[vpc_networks]]
binding = "PRIVATE_NETWORK"
network_id = "cf1:network"
remote = true

Full Translation

Translations

A translation section that keeps the flow of the original article.

openaijamodel: gpt-5-mini-2025-08-07

Workers VPC — VPC Networks経由のconnect()によるTCP接続

概要

VPC Network binding は、fetch() による HTTP トラフィックに加えて、プライベート宛先への生の TCP 接続のための connect() Socket API をサポートするようになりました。これにより、Workers はバインドされた Cloudflare Tunnel、Cloudflare Mesh、または Cloudflare WAN on-ramp を経由して到達可能な任意のプライベートサービス(例: Redis、Memcached、MQTT、カスタムバイナリプロトコル、その他の TCP ベースのサービス)に対して TCP ソケットを開くことができます。

  • 対象例: Redis、Memcached、MQTT、カスタムバイナリプロトコル、その他 TCP ベースのサービス
  • 到達経路: Cloudflare Tunnel、Cloudflare Mesh、Cloudflare WAN on-ramp

設定 (wrangler.jsonc / wrangler.toml)

JSONC

{
 " $schema " : "./node_modules/wrangler/config-schema.json" ,
 " vpc_networks " : [
   {
     " binding " : "PRIVATE_NETWORK" ,
     " network_id " : "cf1:network" ,
     " remote " : true
   }
 ]
}

TOML

[[ vpc_networks ]]
binding = "PRIVATE_NETWORK"
network_id = "cf1:network"
remote = true

実行時の使用例

TypeScript

export default {
  async fetch ( request : Request , env : Env ) {
    // Open a TCP connection to a private Redis instance
    const socket = await env . PRIVATE_NETWORK . connect ( "10.0.1.50:6379" ) ;
    // Write a Redis PING command
    const writer = socket . writable . getWriter () ;
    await writer . write ( new TextEncoder () . encode ( "PING \r\n " )) ;
    await writer . close () ;
    return new Response ( socket . readable ) ;
  },
};

制限事項

  • 現在、VPC Networks 経由の connect() はプレーンテキスト TCP のみをサポートしています。

詳しい情報は VPC Networks と Workers Binding API を参照してください。