← Back to Blog

Running n8n on Raspberry Pi with Cloudflare Tunnel

2023-12-28selfhosted15 min read
Want to run powerful automation workflows without expensive cloud infrastructure? A Raspberry Pi 4 with n8n and Cloudflare Tunnel gives you enterprise-grade capabilities for minimal cost. WHY RASPBERRY PI + N8N Low cost (around $75 for an RPi 4), low power draw (under 10W at idle), reliable enough to run 24/7, flexible thanks to Docker support for any workload, and fully private since it runs entirely in your own network. HARDWARE REQUIREMENTS A Raspberry Pi 4 with at least 4GB of RAM (8GB recommended), an SSD rather than a USB drive for reliable I/O, a proper USB-C power supply, and wired Ethernet for stability. INSTALLATION OVERVIEW Start with Ubuntu Server 24.04 LTS flashed to an SSD. Update the system and install Docker and Docker Compose. Deploy n8n as a Docker container with a persistent volume for its data, setting the host, protocol, port, and webhook tunnel URL as environment variables. Install Cloudflare Tunnel (cloudflared), authenticate it against your Cloudflare account, create a tunnel, and configure ingress rules that route your chosen hostname to the local n8n port. Register cloudflared as a system service so it survives reboots. DNS CONFIGURATION In the Cloudflare dashboard, create a CNAME record pointing your n8n subdomain to your tunnel's assigned address. SECURING YOUR INSTANCE Set a strong n8n password, enable Cloudflare rate limiting, use a properly scoped Cloudflare API token, enable WAF rules, and review logs regularly. MONITORING Add Prometheus and Grafana containers to your Docker Compose stack for visibility into resource usage and workflow execution health. PERFORMANCE TIPS Use an SSD for better I/O, limit simultaneous workflows, archive completed executions regularly, monitor memory usage, and set up log rotation. COST ANALYSIS Roughly $75 for the Raspberry Pi, $80 for a 1TB SSD, $0 for Cloudflare's free tier, and about $10 per year in electricity — a total first-year cost near $165, versus $300 or more per month for comparable cloud alternatives. This setup can handle dozens of concurrent workflows and is perfect for small to medium businesses.

Ready to implement these strategies?

Let's Talk