Blog About Me Posts By Tags Subscribe Elastic Search My Sessions Terraform

Pavan Kumar Aryasomayajulu


Exposing My API Hosted On Localhost To External World Through Internet

Hi, I Just want to share details about a very useful tool, I really liked it and may be you’ll also like it.

Lets say i have a Restful service(example webapi code) in my PC , i am running it on port 4000.

So something like http://localhost:4000/getEmployeeDetails will display my employee details.

Now I want these services to be used instantly by some mobile app or someone through the internet for testing.

First of all, I don’t have a domain or server to host my service and expose it over the internet even for testing.

Now what I can do is I can download an exe provided by ngrok https://ngrok.com/

You can simply download the zip file and unzip where ever we want in our file system.
Let’s say I unzipped it in C:\Sotwares folder

And now from command prompt execute the following command.
Now follow these steps:

  1. Open the command prompt and execute the following command.
  2. So let’s say our API is exposed through port 4000. That is when I browse http://localhost:4000/getEmployeeDetails,
  3. I’ll get employee details.
  4. I need to execute below commands
cd C:\Softwares
ngrok http 4000

  1. Now it will provide you with an URL like http://abcfdd.ngrok.io Now I can give this URL to someone and they can access it through the internet.

So to access my Employee service hosted on my local machine I need to simply give http://abcfdd.ngrok.io/getEmployeeDetails

This really helps us to quickly do some testing.

Keywords: Ngrok, Tunnelling



Thanks, Pavan

#ngrok