Testing Webhooks Locally with Ngrok

Last updated on an hour ago

When developing integrations with third-party services like Twilio, Telnyx, or Stripe, we often rely on webhooks—requests sent from public services to our backend. However, during development, our backend typically runs on a local machine behind a NAT or firewall, making it inaccessible from the outside world. This is where Ngrok comes in.

🌍 What is Ngrok?

Ngrok is a tunneling service that exposes your local server to the internet via a secure URL. It creates a public HTTPS endpoint that forwards requests to your localhost. This is ideal for testing webhooks, APIs, or any local services that need to be accessed remotely.

🔗 Official Docs: Ngrok Documentation

🕒 When to Use Ngrok

You should use Ngrok when:

  • Testing webhooks from third-party services like Twilio, Stripe, or GitHub.

  • Developing and debugging APIs locally before deploying to the cloud.

  • Demoing or sharing your local web app with teammates or clients.

  • Running serverless functions (e.g., Firebase Functions) locally that need external triggers.

Image Reference: https://youtu.be/1iVQEFi_bhc?si=lx8iP82o775xqnqu

👨‍💻 Who Should Use It?

  • Backend developers who integrate with external services.
  • Full-stack engineers testing full request-response cycles locally.
  • QA and DevOps teams simulating real-world scenarios before deployment.
  • Startup teams and solo developers who want to move fast without needing public cloud deployments for every test.

🚀 How to Use Ngrok

Here’s a step-by-step guide to run and test a webhook using Ngrok:

Step1:

Create a Ngrok account https://dashboard.ngrok.com/login

Step2:

Go to https://ngrok.com/ download Ngrok

Mac:

1
brew install ngrok
1
ngrok config add-authtoken <token>
1
ngrok http 5003

Windows:

1
choco install ngrok
1
ngrok config add-authtoken <token>
1
ngrok http 5003

Ngrok service url http://localhost:5003

My Ngrok url Example(https://mutual-driven-warthog.ngrok-free.app)

Step3:

Config Service Webhook URL:

Take my Twilio Webhook service for example

1
2
3
4
const twilioWebhookUri =
isLocal || isDev
? "https://mutual-driven-warthog.ngrok-free.app/<Google Service Name>/<Google Service Region>/api/twilio/receive-sms"
: "https://xxxxxxxxxxxxxxx";

Step4:

Copy whole URL to Third Party Webhook setting

1
2
3

Twilio Example:
https://mutual-driven-warthog.ngrok-free.app/<Google Service Name>/<Google Service Region>/api/twilio/receive-sms

Step5:

Use Postman Testing Webhook

Twilio Example:

1
Post Reauest: https://api.twilio.com/2010-04-01/Accounts/<messageServiceSid>/Messages.json


Testing Webhooks Locally with Ngrok
https://637techlife.com/2025/06/20/Testing Webhooks Locally with Ngrok/
Author
Shang Chien Liu
Posted on
June 20, 2025
Updated on
June 20, 2025
Licensed under