
Accessing your Home Assistant instance remotely can be challenging, especially when dealing with dynamic IP addresses and security concerns. Opening ports on your router creates potential security vulnerabilities, while dynamic IPs make traditional DDNS solutions unreliable. Fortunately, there's a better way: using Cloudflare Tunnel for secure remote access without opening any ports.
Why Avoid Port Forwarding?
Opening ports on your router exposes your Home Assistant instance directly to the internet, creating potential entry points for attackers. Additionally, most home internet connections use dynamic IP addresses that change periodically, making traditional remote access methods unreliable.
What You'll Need
- A Home Assistant installation (Supervised, Container, or Core)
- A domain name (you can use a free subdomain from Cloudflare)
- Cloudflare account
- SyncMyIP account (optional but recommended)
Setting Up Cloudflare Tunnel
Step 1: Install Cloudflared
First, install the Cloudflare Tunnel client (cloudflared) on your Home Assistant server:
curl -L https://bin.equinox.io/c/VdrWdbjqyF/cloudflared-stable-linux-amd64.deb -o cloudflared.deb sudo dpkg -i cloudflared.deb
Step 2: Authenticate with Cloudflare
Log in to your Cloudflare account:
cloudflared tunnel login
This will open a browser window where you'll authenticate with your Cloudflare credentials.
Step 3: Create a Tunnel
Create a new tunnel with a descriptive name:
cloudflared tunnel create home-assistant-tunnel
This command generates a JSON credentials file in ~/.cloudflared/.
Step 4: Configure the Tunnel
Create a configuration file at ~/.cloudflared/config.yml:
tunnel: home-assistant-tunnel
ingress:
- hostname: your-domain.com
service: http://localhost:8123
- service: http_status:404Replace your-domain.com with your actual domain.
Step 5: Route Your Domain
Associate your domain with the tunnel:
cloudflared tunnel route dns home-assistant-tunnel your-domain.com
Step 6: Run the Tunnel
Start the tunnel service:
cloudflared tunnel run home-assistant-tunnel
Setting Up SyncMyIP for Dynamic DNS
While Cloudflare Tunnel handles the connection, SyncMyIP can help manage your domain's DNS records:
- Sign up for a SyncMyIP account
- Add your domain to SyncMyIP
- Configure your router or a device to update SyncMyIP with your current IP
Making It Permanent
To run Cloudflare Tunnel as a service:
sudo cloudflared service install sudo systemctl start cloudflared sudo systemctl enable cloudflared
Security Benefits
- No ports need to be opened on your router
- All traffic is encrypted end-to-end
- Cloudflare's DDoS protection is automatically applied
- Your home IP address remains hidden
Troubleshooting Tips
- Ensure your Home Assistant is accessible locally before setting up the tunnel
- Check that cloudflared has proper permissions to run as a service
- Verify your domain's DNS settings in Cloudflare
- Monitor Cloudflare's dashboard for tunnel connection status