Create a Traffic Policy file
On the system where your Minecraft server runs, create a file named What’s happening here?
This policy checks whether every TCP connection originates from an IP address matching one on the
minecraft.yaml and paste in the policy below, replacing $YOUR_IP and $FRIEND_IP with public IPs.
If you or your friends don’t know theirs, ngrok has a simple helper page that returns your public IP address.allow list.
If they match, the policy allows them connect to your ngrok agent and your Minecraft server, but if they don’t, ngrok denies the request.Start your Minecraft endpoint
On the same system where Minecraft runs, start your ngrok agent on port Once the agent starts, take note of the random public TCP address assigned to your Minecraft server, like
25565, which is the default for Minecraft, and include the minecraft.yaml file you just created.tcp://8.tcp.us-cal-1.ngrok.io:10891.Optional: Get a permanent TCP address
With a production pay-as-you-go account, you can reserve a permanent TCP address for your Minecraft server, which means you and others won’t need to change the URL after restarting the server or its host machine. Navigate to the Domains section of the ngrok dashboard and click New + to reserve the TCP address. Next, restart your agent, replacingtcp://1.tcp.ngrok.io:12345 with the TCP address you reserved.
What’s next?
- Read the Minecraft guide for details on free plan limitations and troubleshooting.
- View your Minecraft traffic in Traffic Inspector to verify that your IP restrictions are working.
- Track your monthly bandwidth and Traffic Policy executions on your usage page to stay aware of any limitations you might reach, particularly on ngrok’s free plan.
- Read more about Traffic Policy, core concepts, and actions you might want to implement next.