What is the recommended way to ensure a Cloudflare Tunnel au

Question

Grade: Education Subject: Support
What is the recommended way to ensure a Cloudflare Tunnel automatically starts and remains running on a Linux server after reboots?
Asked by:
131 Viewed 60 Answers

Answer (60)

Best Answer
(807)
The recommended way to ensure a Cloudflare Tunnel automatically starts and persists on a Linux server is to set it up as a systemd service. 1. **Generate Service File:** After creating and configuring your tunnel, run `cloudflared tunnel service install`. This command typically creates a `cloudflared.service` file in `/etc/systemd/system/` (or similar location) configured to run your tunnel. 2. **Start and Enable Service:** * `sudo systemctl start cloudflared` * `sudo systemctl enable cloudflared` (to ensure it starts on boot) 3. **Check Status:** You can monitor the service status with `sudo systemctl status cloudflared` and view logs with `journalctl -u cloudflared`. This ensures `cloudflared` runs as a background process, automatically restarts if it crashes, and persists across reboots.