Exposing Local Projects to the Web with Cloudflared: A Quick Guide

🚀 Introduction

Ever needed to quickly share a local project with someone without deploying it? Cloudflared makes it incredibly easy to expose your local development server to the web temporarily. Whether you’re showing off a new feature, getting feedback on a design, or testing an API, Cloudflared tunnels provide a secure, instant solution.

⚡ Quick Setup

Installation

# Ubuntu/Debian
curl -L --output cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64.deb
sudo dpkg -i cloudflared.deb

# Verify installation
cloudflared --version

📋 Basic Commands Reference

CommandDescriptionQuick Example
cloudflared tunnel --urlCreate temporary tunnel to local servicecloudflared tunnel --url http://localhost:8000
cloudflared tunnel loginAuthenticate with Cloudflare accountcloudflared tunnel login
cloudflared tunnel createCreate a named permanent tunnelcloudflared tunnel create my-project
cloudflared tunnel listList all your tunnelscloudflared tunnel list
cloudflared tunnel runRun a named tunnelcloudflared tunnel run my-project
cloudflared tunnel cleanupClean up tunnel connectionscloudflared tunnel cleanup my-project
cloudflared --versionCheck current versioncloudflared --version
cloudflared updateUpdate to latest versioncloudflared update

🎯 Quick Start Examples

Example 1: Share a Simple HTML Page

  1. Create a test HTML file:
<!DOCTYPE html>
<html>
<head><title>My Project</title></head>
<body>
    <h1>Hello from my local server!</h1>
    <p>This is being served from my development machine.</p>
</body>
</html>
  1. Start a local server:
# Navigate to your project directory
cd ~/my-project

# Start Python's built-in server
python3 -m http.server 8000
  1. Create the tunnel:
# In another terminal
cloudflared tunnel --url http://localhost:8000
  1. Share the URL: You’ll see output like:
Your quick Tunnel has been created! Visit it at:
https://abc123def.trycloudflare.com

Example 2: Share a React Development Server

# Start your React dev server
npm start
# Server runs on http://localhost:3000

# Create tunnel (new terminal)
cloudflared tunnel --url http://localhost:3000

Example 3: Share a Flask API

# Start Flask app
python app.py
# API runs on http://localhost:5000

# Create tunnel
cloudflared tunnel --url http://localhost:5000

🔧 Advanced Usage

Named Tunnels for Persistent Access

# 1. Login to Cloudflare
cloudflared tunnel login

# 2. Create named tunnel
cloudflared tunnel create my-dev-project

# 3. Run the tunnel
cloudflared tunnel run my-dev-project

Configuration File (config.yml)

tunnel: my-dev-project
credentials-file: ~/.cloudflared/my-dev-project.json

ingress:
  - hostname: my-project.example.com
    service: http://localhost:8000
  - service: http_status:404

💡 Use Cases

🎨 Design Reviews

Share your latest UI changes with designers and stakeholders instantly.

🔧 API Testing

Let backend developers test your API endpoints without complex deployments.

📊 Data Science Projects

Share Jupyter notebooks or data visualizations with colleagues.

🎯 Client Presentations

Demonstrate work-in-progress features to clients securely.

🧪 QA Testing

Allow QA teams to test features before they’re production-ready.

⚠️ Important Notes

Security Considerations

  • Temporary tunnels are perfect for short-term sharing
  • Named tunnels require Cloudflare account authentication
  • URLs are publicly accessible – don’t expose sensitive data
  • Always stop tunnels when you’re done sharing

Duration

  • Quick tunnels: Active until you stop the process
  • Named tunnels: Can run indefinitely until manually stopped
  • No uptime guarantees for free temporary tunnels

🛠️ Troubleshooting

Common Issues

“Connection refused” error:

# Check if your local server is running
curl http://localhost:8000

# Verify the port is correct
netstat -tulpn | grep :8000

Tunnel not accessible:

# Check tunnel status
cloudflared tunnel list

# Restart tunnel
cloudflared tunnel cleanup my-tunnel
cloudflared tunnel run my-tunnel

Port already in use:

# Find what's using the port
lsof -i :8000

# Kill the process
kill -9 <PID>

🧹 Cleanup Commands

ActionCommand
Stop current tunnelCtrl + C
Kill all cloudflared processespkill cloudflared
Stop specific tunnelcloudflared tunnel cleanup <tunnel-name>
Check active processesps aux | grep cloudflared

🎓 Pro Tips

  1. Test locally first – Always verify http://localhost:PORT works before creating a tunnel
  2. Use descriptive tunnel names – Makes management easier
  3. Keep track of active tunnels – Use cloudflared tunnel list regularly
  4. Set up aliases for common commands:# Add to ~/.bashrc or ~/.zshrc alias tunnel='cloudflared tunnel --url' alias tunnels='cloudflared tunnel list'
  5. Combine with tmux/screen for persistent sessions

🔗 Resources


This guide is perfect for developers who need to quickly share local projects without the complexity of full deployments. Cloudflared makes secure, temporary exposure of local services incredibly simple and accessible.

Have you used Cloudflared for your projects? Share your experiences in the comments!

#cloudflared #webdevelopment #devops #cloudflare #localdevelopment

Share