AWS IOT: How to get a public URL instantly using the open source Tunnelmole

Developing for the Internet of Things (IoT) often involves connecting devices that are tucked away on local networks. While AWS IoT provides a powerful platform for managing these devices, a common challenge arises when you need to expose a service run…


This content originally appeared on DEV Community and was authored by Robbie Cahill

Developing for the Internet of Things (IoT) often involves connecting devices that are tucked away on local networks. While AWS IoT provides a powerful platform for managing these devices, a common challenge arises when you need to expose a service running on one of them—like a web server or an API—to the public internet. This is crucial for tasks like testing webhook integrations, remote a web-based dashboard, or sharing your work with colleagues.

Traditionally, getting a public URL for a device on a local network requires complex network configuration like setting up port forwarding on your router, dealing with dynamic DNS, or deploying a reverse proxy. These solutions can be time-consuming, insecure if not done correctly, and sometimes impossible if you are behind a CGNAT or corporate firewall.

This is where Tunnelmole comes in. Tunnelmole is an open-source tunneling tool that creates a secure tunnel from your local machine to the public internet, giving you a stable HTTPS URL in seconds. In this guide, we'll walk you through how to use Tunnelmole to get a public URL for a simple web service running on a device managed by AWS IoT.

What is AWS IoT?

AWS IoT Core is a managed cloud service from Amazon Web Services that lets connected devices easily and securely interact with cloud applications and other devices. It acts as a central message broker, allowing you to connect billions of devices and route trillions of messages to AWS services without managing infrastructure.

Developers use AWS IoT to build a wide range of applications, from smart homes and industrial automation (IIoT) to connected vehicles and healthcare monitoring. A typical setup involves a lightweight client (like an MQTT client) on the IoT device communicating with the AWS IoT Core endpoints. However, sometimes you need more than just MQTT; you might need to run a full-fledged HTTP server directly on your device.

Why You Need a Public URL for Your AWS IoT Device

While AWS IoT Core is excellent for device-to-cloud communication, there are many scenarios where a direct public URL to your device is invaluable:

  • Testing Webhooks: If your IoT application needs to receive data from third-party services like Stripe, Twilio, or IFTTT, you need a public webhook URL. These services can't connect to localhost.
  • Remote Dashboards: You might run a web-based dashboard on your device to display sensor data or control actuators. A public URL lets you access this dashboard from anywhere, on any device, without being on the same Wi-Fi network.
  • API Development and Testing: If your IoT device exposes a REST or GraphQL API, a public URL allows front-end developers or mobile apps to connect to it during development, without needing to deploy the API to a staging server.
  • Demos and Collaboration: Quickly share a working prototype with a client or team member by sending them a public link. They can interact with the live device without any complex setup on their end.
  • Simplified Configuration: Avoid the hassle and security risks of configuring port forwarding, firewalls, and dynamic DNS.

Getting a Public URL Instantly with Tunnelmole

Tunnelmole is a simple command-line tool that solves the public URL problem with a single command. It's open-source, written in TypeScript, and is optionally self-hostable for complete control over your data and infrastructure.

How Tunnelmole Works

Tunnelmole works by establishing a secure WebSocket connection from the client running on your machine (or IoT device) to a public Tunnelmole service host. When a request comes into your public URL, the service forwards it through this persistent connection to your local client. The client then forwards the request to your locally running web server (e.g., an Express.js app). The response travels back the same way.

How Tunnelmole Works

This architecture means you don't need to open any ports on your firewall or have a public IP address. It works from almost anywhere with an internet connection.

Installation

There are two primary ways to install Tunnelmole.

1. Install with a single command (Linux, macOS, WSL)

If you are on a compatible system, you can copy and paste this command into your terminal. The script will detect your OS and install the correct pre-compiled binary.

curl -O https://install.tunnelmole.com/xD345/install && sudo bash install

2. Install with NPM

If you have Node.js (version 16.10 or later) installed on your system, you can use npm to install Tunnelmole globally.

sudo npm install -g tunnelmole

This is often the easiest method for devices like a Raspberry Pi where Node.js is already part of your development stack.

For Windows-specific instructions or to download a pre-compiled binary directly, visit the official Tunnelmole website.

Use Case: Exposing a Simple Express.js Dashboard on an IoT Device

Let's demonstrate how to use Tunnelmole with a practical example. Imagine you have a Node.js application running on an IoT device (like a Raspberry Pi) that serves a simple web page showing a "Hello World" message. We want to make this web page accessible from the internet.

Step 1: Create the Express.js Application

First, let's create our simple web server. Create a new directory for your project and add a file named server.js.

mkdir iot-dashboard
cd iot-dashboard
touch server.js

Now, open server.js in a text editor and add the following code:

const express = require('express');
const app = express();
const port = 3000;

// A simple route that returns a "Hello World" message
app.get('/', (req, res) => {
    res.send('<h1>Hello from my IoT Device!</h1><p>This page is being served by an Express.js app and exposed with Tunnelmole.</p>');
});

app.listen(port, () => {
    console.log(`IoT dashboard server listening at http://localhost:${port}`);
});

This code creates a basic Express server that listens on port 3000 and responds with a simple HTML message at the root URL.

Step 2: Install Dependencies

Our application uses the express package. Let's install it using npm.

npm install express

This will create a node_modules directory and a package.json file.

Step 3: Run the Local Server

Now, start the server to make sure it's working locally.

node server.js

You should see the message: IoT dashboard server listening at http://localhost:3000. You can open a browser on the device and navigate to http://localhost:3000 to see your "Hello World" page.

Step 4: Expose Your Server with Tunnelmole

With the server running, open a new terminal window (or a new SSH session to your device). Now, run Tunnelmole and tell it to forward public traffic to your local port 3000.

tmole 3000

Tunnelmole will start up and provide you with public URLs:

$ tmole 3000
Your Tunnelmole Public URLs are below and are accessible internet wide. Always use HTTPs for the best security

https://cqcu2t-ip-49-185-26-79.tunnelmole.net ⟶ http://localhost:8080
http://cqcu2t-ip-49-185-26-79.tunnelmole.net ⟶ http://localhost:8080

And that's it! You now have a public, secure HTTPS URL that points directly to the web server running on your IoT device.

Step 5: Test the Public URL

Copy the https URL provided by Tunnelmole and paste it into a web browser on any other device—your phone, your laptop, a friend's computer. As long as it has an internet connection, it will be able to access your IoT device's web page.

Advanced Tunnelmole Features

Tunnelmole offers more than just random URLs. Here are a couple of features you might find useful for more permanent or professional setups.

Custom Subdomains

For a more stable and memorable URL, you can use a custom subdomain. This feature is available with a paid subscription on the public Tunnelmole service or for free if you self-host.

The command is simple:

tmole 3000 as my-iot-dashboard.tunnelmole.net

Now your dashboard will be consistently available at https://my-iot-dashboard.tunnelmole.net. This is perfect for bookmarking or configuring in third-party services that need a stable webhook URL.

Conclusion

Connecting your AWS IoT projects to the wider web doesn't have to be a complex or insecure process. Open-source tools like Tunnelmole empower developers to create public endpoints for their local services in seconds. Whether you're debugging webhooks, building a remote-access dashboard, or collaborating with a team, getting a public URL is now as simple as running a single command.

By removing the network configuration bottleneck, you can spend more time focusing on what really matters: building innovative and useful IoT applications. Give Tunnelmole a try on your next project and see how much faster you can move from local development to a publicly accessible prototype.


This content originally appeared on DEV Community and was authored by Robbie Cahill


Print Share Comment Cite Upload Translate Updates
APA

Robbie Cahill | Sciencx (2025-07-12T02:48:05+00:00) AWS IOT: How to get a public URL instantly using the open source Tunnelmole. Retrieved from https://www.scien.cx/2025/07/12/aws-iot-how-to-get-a-public-url-instantly-using-the-open-source-tunnelmole/

MLA
" » AWS IOT: How to get a public URL instantly using the open source Tunnelmole." Robbie Cahill | Sciencx - Saturday July 12, 2025, https://www.scien.cx/2025/07/12/aws-iot-how-to-get-a-public-url-instantly-using-the-open-source-tunnelmole/
HARVARD
Robbie Cahill | Sciencx Saturday July 12, 2025 » AWS IOT: How to get a public URL instantly using the open source Tunnelmole., viewed ,<https://www.scien.cx/2025/07/12/aws-iot-how-to-get-a-public-url-instantly-using-the-open-source-tunnelmole/>
VANCOUVER
Robbie Cahill | Sciencx - » AWS IOT: How to get a public URL instantly using the open source Tunnelmole. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/07/12/aws-iot-how-to-get-a-public-url-instantly-using-the-open-source-tunnelmole/
CHICAGO
" » AWS IOT: How to get a public URL instantly using the open source Tunnelmole." Robbie Cahill | Sciencx - Accessed . https://www.scien.cx/2025/07/12/aws-iot-how-to-get-a-public-url-instantly-using-the-open-source-tunnelmole/
IEEE
" » AWS IOT: How to get a public URL instantly using the open source Tunnelmole." Robbie Cahill | Sciencx [Online]. Available: https://www.scien.cx/2025/07/12/aws-iot-how-to-get-a-public-url-instantly-using-the-open-source-tunnelmole/. [Accessed: ]
rf:citation
» AWS IOT: How to get a public URL instantly using the open source Tunnelmole | Robbie Cahill | Sciencx | https://www.scien.cx/2025/07/12/aws-iot-how-to-get-a-public-url-instantly-using-the-open-source-tunnelmole/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.