Overview
Ahh CLI provides instant tunneling capabilities using Cloudflare’s infrastructure. The tunneling feature allows you to expose local development servers to the internet with a public HTTPS URL, making it perfect for:- Testing webhooks from external services
- Sharing local development with clients or team members
- Accessing local services remotely
- Mobile device testing
How It Works
Ahh CLI usescloudflared under the hood to create secure tunnels. When you run the tunnel command, it:
- Spawns a cloudflared process targeting your local port
- Monitors the process output to extract the tunnel URL
- Returns a public HTTPS URL (e.g.,
https://xyz-abc-123.trycloudflare.com) - Optionally generates a QR code for easy mobile access
Cloudflare free tunnels are rate-limited. If you encounter rate limiting, consider configuring a tunnel on your own domain.
Basic Usage
Tunnel a Local Port
Expose any local port to the internet:Example Output
Implementation Details
Tunnel URL Detection
The CLI uses a regex pattern to extract the tunnel URL from cloudflared’s stderr output:/home/daytona/workspace/source/ahh-binary/src/commands/tunnel/main.ts:1-9
Process Management
The tunnel function spawns cloudflared and monitors its stderr stream:/home/daytona/workspace/source/ahh-binary/src/commands/tunnel/main.ts:11-46
Rate Limiting Detection
The implementation detects and reports rate limiting issues:/home/daytona/workspace/source/ahh-binary/src/commands/tunnel/main.ts:27-35
Use Cases
Webhook Development
Test webhooks from services like GitHub, Stripe, or Twilio without deploying to a server.
Client Demos
Share your local development environment with clients or stakeholders for immediate feedback.
Mobile Testing
Use the generated QR code to quickly access your local server on mobile devices.
Remote Access
Access your local development server from anywhere, even behind NAT or firewalls.
Advanced Patterns
Combining with Other Commands
The tunnel functionality is used internally by other commands likeserve and webhook:
Managing Tunnel Lifecycle
The tunnel function returns a kill method for cleanup:Troubleshooting
Rate limited by Cloudflare
Rate limited by Cloudflare
If you see “429 Too Many Requests”, you’ve hit Cloudflare’s rate limit for free tunnels. Solutions:
- Wait a few minutes before trying again
- Configure a custom tunnel on your own domain
- Use a different network connection
Tunnel URL not appearing
Tunnel URL not appearing
Ensure:
cloudflaredis installed and in your PATH- Your local port is accessible and not blocked by a firewall
- You have a stable internet connection
Connection refused errors
Connection refused errors
Make sure your local server is actually running on the specified port before starting the tunnel.
Best Practices
- Use for development only - Tunnels should be used for testing and development, not production traffic
- Secure your endpoints - Implement authentication even for development tunnels
- Monitor tunnel lifetime - Free tunnels may disconnect; monitor the connection status
- Clean up processes - Always kill tunnel processes when done to free up resources
Related Commands
- Webhook Server - Receive and inspect webhooks with tunneling
- File Serving - Serve static files with automatic tunneling
Technical Reference
Command Options
| Option | Alias | Type | Required | Description |
|---|---|---|---|---|
--port | -p | number | Yes | Local port to tunnel |
Return Value
The tunnel function returns an object with:Dependencies
- cloudflared: Must be installed on your system
- Bun runtime: Used for process spawning and stream handling
