In this article, we are going to install Ngrok on Windows. This method will help you expose your local website, it could be for debugging or testing a callback or webhook URL. Or you want to expose your local web server to present to a client.
You can know more about it from the URL https://www.ngrok.com. It offers a free version and paid version. This article will focus on how we can set up ngrok on Windows 10 machines.
Steps to Install Ngrok
I. Register and login from ngrok website
2. Navigate to the Setup & Installation page then download Ngrok for Windows.
3. Extract the downloaded zip file.
4. Copy the extracted file to a permanent location. In my case, I create a folder on my “D:// Drive” and named it ngrok.
5. Register the location on your window’s environment variables. This will make the ngrok application accessible on Windows command prompt or PowerShell. Search for Environment Variables on your startup.
6. Select Environment Variables from the System properties windows.
7. Search for Path under System Variables then click the Edit button.
8. add the path to the ngrok.exe file by clicking the New button and paste the directory to ngrok.exe. Then click the OK button.
9. To test if the ngrok is accessible, open the command prompt and execute this command “ngrok -v“. See the image below.
10. Connect your ngrok account by executing the command below. You can get auth token from the ngrok dashboard.
ngrok config add-authtoken 2OJGogfwdgZMPPYC7B8H4W5p1Js_4vLB9dSCFiFWYYr9177MZ
To use ngrok, you just need to run your localhost application locally. Then make sure to take note of the port used. For example, if you have a Visual Studio ASP.NET project like below.
Take note of the port used and then open the command prompt and execute the command below.
ngrok http 63752 --host-header="localhost:63752"
Now, if you successfully run Ngrok, a URL will be generated and it’s pointing to your localhost with the specified port that you use. This time you can now access your localhost URL outside your network in real-time by using the generated URL of Ngrok.
If you are using port 443 or HTTPS on your local you can use the command below to forward ngrok on port 443.
ngrok http https://localhost --host-header="localhost:443"
We have successfully set up Ngrok on a Windows machine in this article, we have also highlighted points on where we can use Ngrok. Hopefully, this article gave you an idea or solution to the problem most developers are looking for.