As a developer working with payment gateways and webhooks, testing these integrations in a local development environment is a routine but critical task. Traditionally, I relied on ngrok for this purpose, but its transition to a paid service made it less attractive for occasional use. This prompted me to explore other solutions, leading to a discovery that has significantly simplified my workflow: Cloudflare's tunneling service.
Ngrok has been a staple in many developers' toolkits for testing local servers with external services. However, as ngrok moved to a paid model, the costs for short-term testing became unjustifiable. Alternatives often fell short, plagued by issues like mandatory verification pages that disrupted automated processes. This frustration led me to ask my Twitter network for alternatives, where I discovered Cloudflare's tunneling service.
Cloudflare offers a streamlined approach to tunneling with their cloudflared CLI tool. Here's how you can quickly set up a tunnel on macOS:
First, download the cloudflared tool from Cloudflare's website.
Use the command below to start tunneling your local environment:
cloudflared tunnel --url http://localhost:8080
This will connect http://localhost:8080 to a temporary subdomain at trycloudflare.com. The service provides a randomly generated URL, which you can use to access your local server publicly.

For long-term projects, updating webhook URLs constantly is inefficient. Cloudflare allows the creation of persistent URLs using their DNS service at no additional cost.
cloudflared tunnel login
cloudflared tunnel create myfirsttunnel
url: http://localhost:8080
tunnel: YOUR_TUNNEL_UUID
credentials-file: /root/.cloudflared/YOUR_TUNNEL_UUID.json
Replace YOUR_TUNNEL_UUID with the actual tunnel ID.
sudo cloudflared tunnel ...
cloudflared tunnel route dns myfirsttunnel mysubdomain
cloudflared tunnel run myfirsttunnel
This will set up your tunnel at https://mysubdomain.yourdomain.com
Exploring Cloudflare's tunneling service has been a practical learning experience, enhancing my ability to efficiently test webhooks and payment gateways locally. This exercise underscored the importance of adapting to new tools as older ones evolve or change their service models. While the setup described here is basic, it serves as a foundational step for developers looking to implement more sophisticated configurations.
For those interested in extending their use of Cloudflare's tunneling capabilities beyond the basics, the official Cloudflare documentation offers comprehensive guides and advanced options. This resource is invaluable for customizing and scaling your tunneling configurations to fit more complex project requirements.
This journey through setting up a local testing environment not only resolved immediate logistical challenges but also broadened my understanding of the potential within modern development tools. I encourage other developers to delve into these resources, as mastering such tools can significantly streamline the development and testing processes.