Skip to main content
This guide shows you how to expose your MQTT server to the internet using ngrok. It covers setting up a local MQTT server, creating an ngrok TCP tunnel, and connecting to it using MQTT Explorer.

What you’ll need

1. Start an MQTT server

For this tutorial, use the Eclipse Mosquitto quickstart. Start the server by running this command in your terminal:
The server runs by default on port 1883. You’ll see output like this:

2. Launch ngrok

Once your MQTT server is running successfully on localhost, you can put it online securely using ngrok. Go to the ngrok dashboard and copy your authtoken. Start ngrok by running the following command:
ngrok will display a URL where your localhost application is exposed to the internet. Copy this URL for use with MQTT Explorer.

3. Connect with MQTT Explorer

Open MQTT Explorer and click the plus sign to create a new MQTT connection. Enter the TCP address from the last step and click Connect. You’ll see a few new lines in your MQTT server logs:
MQTT Explorer is now connected to your server over the public internet. To get messages from the client, subscribe to a topic. In your terminal, open a tab and enter:
Back in MQTT Explorer, publish a message to example/topic. You’ll see the message in the terminal tab where you subscribed to the topic: