Skip to main content

Overview

The connect expose command creates a secure tunnel that makes your local services accessible to other agents in your workspace. Whether it’s a database, API, or any TCP/UDP service, Private Connect handles the networking so you can focus on development.
Quick Start: Use the shorthand connect <target> instead of connect expose <target> for faster commands.

Basic Usage

1

Expose a service

Run the command on the machine where your service is running:
connect expose localhost:5432 --name prod-db
Output:
πŸ”— Exposing localhost:5432 as "prod-db"...
   Agent ID: 550e8400-e29b-41d4-a716-446655440000
   Label:    laptop
   Hub URL:  https://api.privateconnect.co

[ok] Service registered
   Service ID: svc_abc123
   Tunnel Port: 40001
   Protocol: tcp

[ok] Connected to hub
[ok] Tunnel established

πŸ“‘ Service "prod-db" is now accessible through the hub

   From another machine:
   $ connect reach prod-db
   This creates a local tunnel so the service appears on localhost

   Running initial diagnostics...

[ok] prod-db is REACHABLE
     DNS [ok]  TCP [ok]  45ms

   Press Ctrl+C to stop exposing
2

Service is now available

Your service is now accessible to other agents in your workspace through the hub.
The tunnel stays active as long as the command is running. Press Ctrl+C to stop exposing the service.

Auto-Naming

Private Connect automatically generates service names based on the port:
connect localhost:5432              # Auto-named "postgres"
connect localhost:6379              # Auto-named "redis"
connect localhost:3306              # Auto-named "mysql"
connect localhost:27017             # Auto-named "mongo"
connect localhost:5432
# Auto-named: postgres

Protocol Support

Private Connect supports multiple protocols with automatic detection:
connect expose localhost:5432 --protocol tcp
The --protocol flag defaults to auto, which intelligently detects the protocol based on traffic patterns.

Public URLs

Create a public URL that anyone can access, perfect for webhooks and demos:
connect expose localhost:3000 --public
Output:
🌐 Public URL: https://abc123.privateconnect.co
   External services (Stripe, GitHub, etc.) can send webhooks to this URL

πŸ“‘ Service "my-app" is now accessible through the hub

   Public URL: https://abc123.privateconnect.co
   Anyone can reach this service at the URL above
Public URLs are not recommended for database services (PostgreSQL, MySQL, Redis, etc.). Use connect reach instead for secure peer-to-peer connections.

Database Services

Private Connect automatically prevents public URLs for database ports:
connect expose localhost:5432 --public
Output:
[!] --public creates a public HTTP URL, which doesn't work for database/TCP services (port 5432).
    To access this service remotely, use: connect reach prod-db
Protected ports: 5432 (PostgreSQL), 3306 (MySQL), 27017 (MongoDB), 6379 (Redis), and more. Create time-limited share links with the --link flag:
connect expose localhost:3000 --link --link-expires 24h
Output:
πŸ”— Public URL: https://x7k9m2.privateconnect.co
   Expires: Mon Mar 03 2026 23:44:00 GMT
Share links are perfect for demos and temporary access. They automatically expire after the specified duration.

Debug Mode

Enable live traffic inspection with the --debug flag:
connect expose localhost:3000 --debug
Output:
πŸ” Debug mode enabled
   Share this link: https://app.privateconnect.co/debug/abc123
   Anyone with this link can see live traffic
With AI assistance:
connect expose localhost:3000 --debug --ai
Output:
πŸ” Debug mode enabled
   Share this link: https://app.privateconnect.co/debug/abc123
   Anyone with this link can see live traffic
   AI Copilot: enabled
Debug mode provides live traffic inspection and AI-powered debugging assistance.

Command Options

OptionDescriptionExample
--name <name>Service name (required for non-standard ports)--name prod-db
--protocol <type>Protocol: auto, tcp, http, https, udp--protocol tcp
--publicCreate a public URL--public
--linkCreate a temporary share link--link
--link-expires <time>Link expiration: 1h, 24h, 7d--link-expires 24h
--debugEnable debug mode with traffic viewer--debug
--aiEnable AI copilot in debug sessions--ai
--hub <url>Hub URL (defaults to production)--hub https://api.privateconnect.co
--api-key <key>API key for authentication--api-key pc_xxx
--config <path>Path to config file--config ~/.connect/config.json

Examples

# Expose PostgreSQL with explicit name
connect expose localhost:5432 --name prod-db

# Teammates can connect with:
connect reach prod-db

Diagnostics

Private Connect automatically runs health checks when exposing services:
connect expose localhost:3000 --name api
Output:
[ok] Tunnel established

   Running initial diagnostics...

[ok] api is REACHABLE
     DNS [ok]  TCP [ok]  HTTP [ok]  32ms
If the service is unreachable:
[x] api is UNREACHABLE
    TCP connection failed: ECONNREFUSED

    Check that your service is running on the target port
Diagnostics help you catch configuration issues early. If a service is unreachable, verify it’s running on the correct port before exposing it.

First-Time Setup

If you haven’t authenticated yet, Private Connect will prompt you:
connect expose localhost:5432 --name db
Output:
[x] API key required for first-time setup
  Run connect login <your-api-key> to save it once
  Or use: connect expose <target> --api-key <your-api-key>
Authenticate once:
connect up --api-key pc_xxx
Then expose services without the API key:
connect expose localhost:5432 --name db

Next Steps

Reach Services

Connect to exposed services from any machine

Share & Collaborate

Share your environment with teammates

Monitoring

Monitor and debug your services

Public Links

Create shareable URLs for webhooks and demos

Build docs developers (and LLMs) love