Skip to content

Instantly share code, notes, and snippets.

@johnidm
Last active February 6, 2026 20:55
Show Gist options
  • Select an option

  • Save johnidm/e4b71b2a25a180ffd69767685cd813cf to your computer and use it in GitHub Desktop.

Select an option

Save johnidm/e4b71b2a25a180ffd69767685cd813cf to your computer and use it in GitHub Desktop.
Local Development with Tunneling

Your local server isn't likely to be accessible from the internet. Use tunneling to expose it temporarily.

Create a local server (testing propouse)

cd /tmp
cat <<'EOF' > index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>My Tunnel</title>
</head>
<body>
    Hi, this is running on my machine!
</body>
</html>
EOF
php -S localhost:8000

Option 1: ngrok (Most Popular)

# Install
brew install ngrok  # macOS
# or download from https://ngrok.com

# Authenticate (free account required)
ngrok config add-authtoken <your-token>

# Start tunnel
ngrok http 8000

Option 2: Cloudflare Tunnel (Free, No Account for Quick Tunnels)

# Install
brew install cloudflared  # macOS

# Quick tunnel (no account needed)
cloudflared tunnel --url http://localhost:8000
curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg \
  | sudo gpg --dearmor -o /usr/share/keyrings/cloudflare-main.gpg

echo "deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared $(lsb_release -cs) main" \
  | sudo tee /etc/apt/sources.list.d/cloudflared.list

sudo apt update
sudo apt install cloudflared

Option 3: localtunnel

npx localtunnel --port 8000

Option 3: VS Code Port Forwarding

  1. Open Ports panel (View → Ports)
  2. Click "Forward a Port"
  3. Enter 3000 (or your port)
  4. Set visibility to "Public"
  5. Use the forwarded URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment