Skip to content

Host Your Projects via Cloudflared Tunnel

This is a showcase of hosting your services from localhost to internet via Cloudflare tunnel managed locally and the local operating system is macOS.

During this road there a few choices localtonet or ngrok or serveo.

In my humble opinion Cloudflare Tunnel is the best option out there. It is free, easy to setup and you can use custom domains.

Cloudflare Tunnel

This is a free feature of Cloudflare introduced by You can find docs by Docs were sufficent in my case except for running the tunnel as service. I had to add configure daemon agent of macOS.

Cloudflare Tunnel

Set up your tunnel


This chapter is exactly same from Get started to create a locally-managed tunnel of official documentation.

Create a Cloudflare Account

I am also using Cloudflare DNS services for my custom domains and I suggest this to easily create custom domain to your local services.

Install cloudflared CLI and Create Tunnel

brew install cloudflare/cloudflare/cloudflared
cloudflared tunnel login
cloudflared tunnel create <tunnel-name>


You can use one tunnel to host more than one service from your localhost so this name does not need to be a service specific name

cloudflared tunnel create <tunnel-name>

Configure Tunnel in macOS

cloudflared tunnel route dns <tunnel-id/tunnel-name> <host-name>
ls /Users/<user-name>/.cloudflared
>   <tunnel-id>.json
tunnel: <tunnel-id>
credentials-file: /Users/<user-name>/.cloudflared/<tunnel-id>.json

    - hostname: <custom-domain-name>
      service: http://localhost:<port>
    - hostname: <custom-domain-name-2>
      service: http://localhost:<port>

Run the Tunnel

  • Run tunnel manually

    cloudflared tunnel run  <tunnel-id/tunnel-name>
    cloudflared tunnel --config /Users/<user-name>/.cloudflared/config.yml run <tunnel-id/tunnel-name>

  • Run tunnel as a user (not system) service in macOS

    cloudflared service install


Extra steps are required to run service according to config file we created. Even though documentation explicitly states it uses automatically the user config file. However in mycase the installed service only created quick try tunnel.

  1. Edit plist config

    cat com.cloudflare.cloudflared.plist
    <><?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
    <plist version="1.0">

  2. Check launchctl service && Boot the com.cloudflare.cloudflared

    launchctl list | grep 'com.cloudflare*'
    launchctl bootout com.cloudflare.cloudflared
    launchctl bootstrap com.cloudflare.cloudflared
    sudo launchctl start com.cloudflare.cloudflared

  3. Check Output and Error files

    cat /Library/Logs/com.cloudflare.cloudflared.err.log
    cat /Library/Logs/com.cloudflare.cloudflared.out.log

3.2 Manually Start/Stop the service

sudo launchctl stop com.cloudflare.cloudflared
sudo launchctl start com.cloudflare.cloudflared
launchctl list | grep 'com.cloudflare*'

Extra Step: Monitoring Services

I have started using Uptime Robot to monitor my services as it is free up to 50 monitors and easy to set up.

Just add the http health url and it is good to go with 5 min. intervals.