Sitemap

NGROK

3 min readDec 24, 2024

--

Your Gateway to Secure and Seamless Local Server Access!

Get Rajanikanth Sugumar’s stories in your inbox

Join Medium for free to get updates from this writer.

Effortlessly expose your local development environment to the internet with Ngrok. Perfect for testing web hooks, sharing demos, and remote debugging — all with security and simplicity at its core.

Introduction to Ngrok and Its Uses

Ngrok is a powerful tool that allows developers to expose a local server to the internet securely. By creating a tunnel from a local machine to the web, Ngrok eliminates the need to configure firewalls, port forwarding, or domain setup for testing purposes. It’s particularly useful for web development, testing webhooks, and demonstrating applications hosted on a local server to remote clients.

Key Features of Ngrok

  1. Secure Tunnels: Ngrok provides HTTPS endpoints, ensuring secure communication.
  2. Custom Subdomains: Developers can use subdomains for easy identification.
  3. Logging and Inspection: Ngrok offers a web interface to inspect and replay requests.
  4. Wide Compatibility: It works on all major platforms including Windows, macOS, and Linux.

Setting Up Ngrok

Step 1: Download Ngrok

  1. Go to ngrok’s official website.
  2. Download the appropriate version for your operating system.
Press enter or click to view image in full size
Various platforms are supported

Step 2: Install Ngrok

  1. Extract the downloaded file.
  2. Move the executable to a location in your system’s PATH (optional, for global access).

Step 3: Sign Up and Authenticate

  1. Create an account on Ngrok’s website to access advanced features.
  2. After logging in, find your authtoken on the dashboard.
  3. Authenticate Ngrok on your machine using:
$ngrok config add-authtoken {your-authtoken}
Press enter or click to view image in full size
Adding Token
Press enter or click to view image in full size
Instructions on the website

Step 4: Start a Tunnel

  1. Run your local server (e.g., a Node app on port 3000).
  2. Start Ngrok to expose it:
$ngrok http http://localhost:3000

3. Ngrok will provide public URLs (both HTTP and HTTPS) that point to your local server.

Press enter or click to view image in full size
Instructions on the website
Press enter or click to view image in full size
Invoking NGROK instance
Press enter or click to view image in full size
NGROK Instantiated

Let’s set up a quick Node.js web server to test it out.

const express = require('express');
const app = express();
const port = 3000;

app.get('/', (req, res) => {
res.send('Server Running');
});

app.listen(port, () => {
console.log(`Server running at http://127.0.0.1:${port}/`);
});
Press enter or click to view image in full size
Install Express npm package
Press enter or click to view image in full size
NODE JS Server Instantiated

Step 5: Use and Share

  • Share the generated URL to allow others to access your local app.
Press enter or click to view image in full size
URL Generated — Forwarding Begun

Common Use Cases

  1. Testing Webhooks: Ngrok simplifies the process of testing webhooks from third-party services like Stripe or GitHub.
  2. Client Demos: Share local projects with clients without deploying them to a production server.
  3. Remote Debugging: Collaborate with teammates to debug local applications.
  4. IoT and Smart Devices: Expose local IoT devices for remote control or testing.

Conclusion

Ngrok is an essential tool for developers, enabling seamless local-to-remote server integration. Whether you’re a web developer testing APIs or demonstrating a prototype to a client, Ngrok saves time and effort by simplifying the process of exposing local environments.

References

  1. https://ngrok.com/
  2. https://medium.com/@PubNub/what-is-ngrok-9f35088c6dcf

--

--