Exposing localhost to the internet

During development you may find yourself in a situation where you may need to access your local development web server from the public web. The most common scenario where this happens is when you need to test and debug webhooks since these need to be accessed from another system on the internet.

For this example we will use ngrok. Ngrok is a tunnelling, reverse proxy software that establishes a tunnel from a public endpoint to your local web server. It is available, free of charge, for all major operating systems. For more information, see the ngrok download page.

These instructions will show you how you can configure ngrok to work with an ASP.NET Core application.
For other languages see the ngok documentation.

Authenticating ngrok

Once you have downloaded and installed ngrok, you will need to connect your ngrok account. Log in to your ngrok account (or register for an account if you don’t have one yet) and go the Auth section of the dashboard. Here you will see your tunnel authentication token listed:

1051

Use that token to authenticate ngrok.

ngrok authtoken 2672z...

Create the tunnel

Now that ngrok is installed and authenticated, you can create a tunnel. First, you need to start your ASP.NET Core application and take note of the port that it is using, specifically the HTTPS port, which is 7264 in the sample below.

688

Start an HTTP tunnel by running the command ngrok http and passing the port.

ngrok http https://localhost:7264 -host-header="localhost:7264"
950

In the status, ngrok will list the public URLs you can use to access your application. We’re interested in the HTTPS URL, so in our case, this is https://87dc-73-228-64-197.ngrok.io



For details on how to debug a Hook, Merchant, Event, or External Page, see how to debug in each section: