Skip to main content
TL;DRTo publish your MQTT server with ngrok:
  1. Start an MQTT server. mosquitto
  2. Launch ngrok. ngrok tcp 1883
  3. Configure MQTT Explorer with your ngrok URL.
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 available on GitHub. Start the server by running this command in your terminal:
mosquitto
The server runs by default on port 1883. You’ll see output like this:
1734408888: mosquitto version 2.0.20 starting
1734408888: Using default config.
1734408888: Starting in local only mode. Connections will only be possible from clients running on this machine.
1734408888: Create a configuration file which defines a listener to allow remote access.
1734408888: For more details see https://mosquitto.org/documentation/authentication-methods/
1734408888: Opening ipv4 listen socket on port 1883.
1734408888: Opening ipv6 listen socket on port 1883.
1734408888: mosquitto version 2.0.20 running

2. Launch ngrok

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

3. Integrate 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:
1734410153: New connection on port 1883.
1734410153: New client connected as mqtt-explorer-ba9b56f9 (p2, c1, k60).
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:
mosquitto_sub -t 'example/topic' -v
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:
example/topic hello world