Ngrok: A Developer’s Gateway to Localhost

Osama HaiDer
3 min readJan 14, 2024

--

What is Ngrok?

Ngrok is a powerful tool designed to address a common challenge faced by developers: the need to expose local servers to the internet for testing and collaboration. It acts as a secure tunnel, allowing you to share your locally hosted web applications and APIs with others over the internet.

Why Use Ngrok? (Use Cases)

  1. Web Development and Testing:
  • Scenario: You’re working on a web application locally and want to test it on various devices or share your progress with teammates or clients.
  • Solution: Ngrok enables you to create a secure tunnel to your local server, providing a public URL for easy access from anywhere.

2. Webhooks Testing:

  • Scenario: You need to test and debug webhooks that your application relies on for external data or events.
  • Solution: Ngrok allows you to expose your local server to the internet, so external services can send HTTP requests to your webhook endpoints for testing purposes.

3. API Development:

  • Scenario: You’re developing an API locally and need to collaborate with others for testing and feedback.
  • Solution: Ngrok helps you share your local API server by creating a secure tunnel, making it accessible to remote team members or external partners.

4. Demo and Showcasing:

  • Scenario: You want to showcase a work-in-progress application or feature to clients or stakeholders without deploying it to a production server.
  • Solution: Ngrok provides a temporary public URL, allowing you to share your local development environment for demonstrations.

Install Ngrok with Visual Studio 2022

Step 1: Download Ngrok

  1. Visit the Ngrok website and sign up for a free account.
  2. After signing up, download the Ngrok ZIP file suitable for your operating system.

Step 2: Extract Ngrok

  1. Extract the contents of the downloaded ZIP file to a location on your computer.

Step 3: Configure Ngrok Authtoken

  1. Open a terminal or command prompt.
  2. Navigate to the directory where you extracted Ngrok.
  3. Run the following command to authenticate Ngrok with your account:
ngrok config add-authtoken YOUR_AUTH_TOKEN
  1. Replace YOUR_AUTH_TOKEN with the authentication token provided on the Ngrok website after signing up.

Step 4: Install Ngrok Extension in Visual Studio 2022

  1. Open Visual Studio 2022.
  2. Go to Extensions > Manage Extensions.
  3. In the Extensions window, search for “Ngrok” in the Online section.
  4. Find the “Ngrok Tunnel Manager” extension and click the Install button.
  5. Restart Visual Studio to complete the installation.

Use Ngrok with Visual Studio 2022

Step 5: Open Visual Studio 2022 Project

  1. Open your Visual Studio 2022 project you want to expose to the internet.
  2. Go to Extensions > Manage Extensions.
  3. Click on “Change your settings for Extensions”.
  4. In the Settings window, search for “Ngrok” in the Installed section.
  5. Select the “Ngrok Tunnel Manager” extension and click “Options.”
  6. In the Options window, navigate to “Ngrok Executable Path.”
  7. Enter the path where Ngrok is located, for example:
C:\Users\your_username\path\to\ngrok.exe

Step 6: Start Ngrok Tunnel from Visual Studio

  1. Open your Visual Studio 2022 project you want to expose to the internet.
  2. Go to Tools > Start Ngrok Tunnel.

Step 7: Now you will see your project added on Ngrok.

Notes:

  • Keep the Ngrok Tunnel Manager window open while you need the public URL to be accessible.
  • Ngrok provides both HTTP and HTTPS URLs. Choose the appropriate one based on your project’s requirements.

By following these steps, you should be able to seamlessly install the Ngrok extension in Visual Studio 2022, configure the Ngrok executable path, and expose your local server to the internet for testing and collaboration directly from Visual Studio.

🤝 Happy Day!

--

--

Osama HaiDer
Osama HaiDer

Written by Osama HaiDer

SSE at TEO International | .Net | Azure | AWS | Web APIs | C#

No responses yet