How to Connect to Miget Services Using Ngrok
In this guide, you'll learn how to connect to a Miget-managed service (like PostgreSQL) that's within a private network using Ngrok. Ngrok enables you to securely expose services running on private networks to the internet through a public endpoint, allowing you to access your PostgreSQL database from anywhere.
Prerequisites
Before we start, make sure you have the following:
-
Miget Account – You should already be registered on Miget.
-
Ngrok Free Tier Account – You will need a free tier Ngrok account.
-
Ngrok Authtoken – After signing up, navigate to the Ngrok dashboard and generate your
NGROK_AUTHTOKEN. -
Miget PostgreSQL Service – We'll assume you have an existing or newly created Miget app with PostgreSQL added as a service.
Steps to Connect to Miget’s Managed PostgreSQL Database Using Ngrok
Create a Miget App
If you haven't created an app yet, follow these steps to create one:
-
In the Miget dashboard, click New to Create a New Aapp.
-
Choose the settings you prefer, and give your app a name like
my-postgres-app.
Add PostgreSQL as an Addon to Your App
-
Navigate to the app you just created and click on Addons -> Add Add-On.
-
Choose PostgreSQL from the list of available services.
Add it to your app and configure the required resources (like PostgreSQL version, memory and storage).
Get PostgreSQL Endpoint (including Port)
Once your PostgreSQL service is running:
-
Go to the PostgreSQL service details of your app (Addons -> View on your newly created postgres).
-
Copy the service hostname and port number, which you will use to set up Ngrok (Click on Show button to get credentials and endpoint details).
Create Another Miget App for Ngrok
Next, we will create an app to run Ngrok:
-
In the Miget dashboard, click New to Create a New Aapp again.
-
Name this app something like
ngrok. -
Once created, proceed to the next step.
Deploy Ngrok from GitHub
To deploy the Ngrok app:
-
Set Builder to
Dockerfileunder Settings -> Builders -
Deploy the Ngrok app from this GitHub repository: https://github.com/migetapp/ngrok
git clone git@github.com:migetapp/ngrok.git -
Follow the deployment instructions provided in the Deploy tab to get it running, something like:
cd ngrok git remote add miget https://git.eu-east-1.miget.io/migetcyy/ngrok-nhfxu git push miget
Note
We used miget of migetcyy and ngrok-nhfxu as an example above.
Add Environment Variables to the Ngrok App
Once the Ngrok app is deployed, you need to add the following environment variables:
-
NGROK_AUTHTOKEN– Obtain this from your Ngrok dashboard. Go to Ngrok Cloud Edge Endpoints Dashboard, next click on Start a Tunnel button. In the right side window, select Start a tunel with a Docker container, copy a content ofNGROK_AUTHTOKENcontent: -
MIGET_SERVICE_NAME– This should be the hostname of the PostgreSQL endpoint from previous steps. -
MIGET_SERVICE_PORT– This should be the port number of the PostgreSQL service (also from previous steps).
Add those ENV Variables to your ngrok App, Settings -> Config Vars -> Edit Config Vars
Get Ngrok Public Endpoint
Navigate to the Ngrok Clouds Edge -> Endpoints section in your Ngrok dashboard. Here, you will find the public endpoint provided by Ngrok.
Connect to Your PostgreSQL Database
Now that you have the public Ngrok endpoint, you can use psql or any PostgreSQL client to connect:
psql -h 0.tcp.eu.ngrok.io -p 18227 -U jkymffki -d h5p37a0n
Note
Replace 0.tcp.eu.ngrok.io and 18227 with the values from previous step. The jkymffki and h5p37a0n should be your PostgreSQL details such username and database name.
Summary
By following these steps, you’ll be able to securely access your Miget-managed PostgreSQL service using Ngrok, even from outside the private network. You can now start managing and querying your database remotely with ease.
Once your Ngrok connection is set up, you can also access other services in a similar fashion by modifying the environment variables for different services.





