When you're developing a project locally, sometimes you need to expose it to the outside world — for testing webhooks (like Stripe, RevenueCat, Razorpay), sharing work with clients or teammates, or testing mobile apps. That’s where Ngrok becomes incredibly useful.
🔍 What is Ngrok?
Ngrok is a tool that creates a secure tunnel to your localhost. It provides a public URL that maps to your local web server. It's perfect for testing APIs, webhooks, or sharing local work without deploying it.
🛠️ How to Install Ngrok
Download it from the official website: ngrok.com/download
# For Linux/macOS:
unzip ngrok-stable-linux-amd64.zip
mv ngrok /usr/local/bin
# For Windows:
# Unzip and run ngrok.exe from CMD or add it to your PATH
🚀 How to Use Ngrok with Your Project
1. Start Your Local Server
For example, if you're running Laravel or Node.js on port 8000
:
php artisan serve
# OR
npm run dev
2. Start Ngrok and Create a Tunnel
Open a new terminal and run:
ngrok http 8000
Explanation:
ngrok
– the command-line toolhttp
– type of tunnel (HTTP server)8000
– the port your app is running on locally
This will output something like this:
Session Status online
Account YourName (Plan: Free)
Version 3.x.x
Forwarding http://abc123.ngrok-free.app -> http://localhost:8000
Forwarding https://abc123.ngrok-free.app -> http://localhost:8000
Important:
- Public URL:
https://abc123.ngrok-free.app
- Local target:
localhost:8000
You can now use this URL to:
- Make API calls from mobile apps
- Set webhook endpoints (e.g., Stripe, Razorpay, RevenueCat)
- Share live demos with clients or teammates
Note: Free Ngrok accounts generate a new public URL each time. For permanent URLs, use a paid plan.
📦 Common Use Cases
- Testing webhooks from RevenueCat, Stripe, Razorpay, etc.
- Client demos of local projects
- Accessing your local project from your phone or tablet
- Debugging incoming HTTP requests
🔐 Optional: Sign Up & Auth Token
To unlock more features, sign up at ngrok.com and configure your auth token:
ngrok config add-authtoken YOUR_AUTHTOKEN
⚙️ Pro Tips
ngrok http 8000 --region=ap
– choose an Asia-Pacific region for faster routing (for users in India, SEA, etc.)ngrok http 8000 --inspect
– enable request inspection in the local dashboardhttp://127.0.0.1:4040
– Ngrok dashboard for inspecting HTTP requests/responses- Create a config file at
~/.ngrok2/ngrok.yml
for reusable tunnel configurations
✅ Conclusion
Ngrok is a must-have tool for any developer working on local environments. Whether you're testing APIs, setting up webhooks, or demoing your work — Ngrok makes it easy and secure to tunnel your local app to the world.
💡 Give it a try on your next project — you’ll love how much time it saves!
Comments
Post a Comment