ngrok Alternative: Complete Setup and Configuration Guide
ngrok has long been the go-to tool for exposing local development servers to the internet. However, as projects scale, developers often run into limitations such as restricted bandwidth on free tiers, random URL changes, and paywalls for custom subdomains. This guide walks you through the best ngrok alternatives, how to install and configure them, and best practices for secure tunneling in production-grade workflows.
Why Consider an ngrok Alternative?
While ngrok is reliable, several pain points push developers to explore alternatives:
- Limited free tier: ngrok's free plan imposes connection limits and random URLs that change on every restart.
- Custom subdomains require paid plans: Webhook testing with stable URLs becomes costly.
- Privacy concerns: Some organizations restrict third-party SaaS tunnels for compliance reasons.
- Self-hosting needs: Teams may want full control over their tunnel infrastructure.
Below, we cover four powerful alternatives: Cloudflare Tunnel, localtunnel, frp (Fast Reverse Proxy), and Pinggy.
1. Cloudflare Tunnel (cloudflared)
Cloudflare Tunnel creates a secure outbound connection from your machine to Cloudflare's edge network. It is free, fast, and integrates seamlessly with Cloudflare's DNS and Zero Trust platform.
Installation
# macOS
brew install cloudflared
# Linux (Debian/Ubuntu)
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb -o cloudflared.deb
sudo dpkg -i cloudflared.deb
# Windows (PowerShell)
winget install --id Cloudflare.cloudflared
Quick Tunnel Without an Account
For instant testing without authentication, run a quick tunnel:
# Start your local server on port 3000
npm run dev
# In another terminal, expose it
cloudflared tunnel --url http://localhost:3000
Cloudflare will output a public URL like https://random-words-xyz.trycloudflare.com. This is perfect for quick demos and webhook testing.
Named Tunnel with Custom Domain
For persistent URLs, authenticate and create a named tunnel:
# Authenticate
cloudflared tunnel login
# Create a tunnel
cloudflared tunnel create my-dev-tunnel
# Configure DNS route (requires a domain on Cloudflare)
cloudflared tunnel route dns my-dev-tunnel dev.example.com
Create a configuration file at ~/.cloudflared/config.yml:
tunnel: my-dev-tunnel
credentials-file: /Users/you/.cloudflared/<TUNNEL_ID>.json
ingress:
- hostname: dev.example.com
service: http://localhost:3000
- service: http_status:404
Run the tunnel:
cloudflared tunnel run my-dev-tunnel
2. localtunnel
localtunnel is a lightweight, open-source Node.js alternative. It is ideal for quick, no-signup tunneling and is fully self-hostable.
Installation and Usage
# Install globally
npm install -g localtunnel
# Expose local port 8080
lt --port 8080
# Request a custom subdomain
lt --port 8080 --subdomain my-custom-name
This produces a URL like https://my-custom-name.loca.lt. Note that localtunnel displays a confirmation page on first visit; pass the Host header or click through to bypass it.
Programmatic Usage
const localtunnel = require('localtunnel');
(async () => {
const tunnel = await localtunnel({ port: 3000, subdomain: 'myapp' });
console.log(`Tunnel URL: ${tunnel.url}`);
tunnel.on('close', () => {
console.log('Tunnel closed');
});
})();
3. frp (Fast Reverse Proxy)
frp is an open-source, self-hosted reverse proxy that gives you complete control. You need a public server (VPS) and your local machine.
Server Setup (frps)
Download frp on your VPS and create frps.ini:
[common]
bind_port = 7000
dashboard_port = 7500
dashboard_user = admin
dashboard_pwd = strongpassword
token = your-secret-token
Start the server:
./frps -c frps.ini
Client Setup (frpc)
On your local machine, create frpc.ini:
[common]
server_addr = your-vps-ip
server_port = 7000
token = your-secret-token
[web]
type = http
local_port = 3000
custom_domains = dev.example.com
Start the client:
./frpc -c frpc.ini
Point your DNS dev.example.com to your VPS IP, and traffic will be routed securely to your local port 3000.
4. Pinggy
Pinggy offers SSH-based tunneling with no client installation required. It is perfect for environments where you cannot install binaries.
Quick Start
# Expose local port 8000 over HTTPS
ssh -p 443 -R0:localhost:8000 a.pinggy.io
Pinggy returns a public HTTPS URL instantly. For a custom subdomain:
ssh -p 443 -R0:localhost:8000 a.pinggy.io subdomain=myapp
Best Practices for Secure Tunneling
- Use authentication tokens: Always secure tunnels with tokens, especially for self-hosted solutions like frp.
- Avoid long-running free tunnels for production: Use named tunnels with custom domains for stability.
- Restrict access with Zero Trust: Cloudflare Tunnel supports identity-based access policies — enable them for sensitive endpoints.
- Monitor tunnel traffic: Use dashboards (frp dashboard, Cloudflare Zero Trust logs) to detect anomalies.
- Rotate credentials: Periodically rotate tokens and SSH keys used for tunnel authentication.
- Use HTTPS only: Ensure your tunnel terminates TLS so local traffic remains encrypted end-to-end.
Conclusion
Choosing the right ngrok alternative depends on your needs: Cloudflare Tunnel is excellent for free, stable, production-grade exposure with custom domains; localtunnel is perfect for quick, no-frills testing; frp gives you full self-hosted control; and Pinggy shines when you cannot install software. By understanding the strengths of each tool and following secure tunneling best practices, you can expose local services confidently without relying on a single vendor. Evaluate your team's requirements around cost, compliance, and control, then adopt the solution that fits your workflow best.