This content originally appeared on DEV Community and was authored by Robbie Cahill
Port Forwarding: The Developer’s Guide to Secure, Effortless Port Forwarding with Tunnelmole
Port forwarding is a critical skill for developers, DevOps engineers, and anyone who needs to expose a local service to the internet. Whether you’re testing webhooks, sharing a local app, or enabling remote access to a development server, port forwarding bridges the gap between your private network and the outside world.
In this comprehensive guide, you’ll learn:
- What port forwarding is and why it matters for modern development
- The challenges of traditional port forwarding (NAT, firewalls, router config)
- How Tunnelmole, an open source tunneling tool, makes port forwarding simple and secure
- Step-by-step instructions to forward ports using Tunnelmole on Linux, Mac, and Windows
- Real-world use cases: webhooks, IoT, mobile testing, and more
- Security best practices and troubleshooting tips
Let’s dive in and unlock the power of port forwarding for your next project.
What is Port Forwarding?
Port forwarding is the process of making a local network service (like a web server running on your laptop) accessible from outside your private network. It’s a foundational technique for:
- Testing APIs and webhooks from third-party services (e.g., Stripe, Shopify, Slack)
- Sharing in-progress web apps with teammates or clients
- Enabling remote access to development environments
- Connecting IoT devices to cloud dashboards
- Running game servers or custom network services
How it works:
Normally, your local server (e.g., localhost:3000
) is only accessible from your own machine. Port forwarding creates a public-facing endpoint that routes incoming traffic to your local port, allowing anyone with the URL to access your service.
Why Traditional Port Forwarding is a Pain
Classic port forwarding usually means:
- Logging into your router’s admin panel
- Configuring NAT rules and firewall exceptions
- Dealing with dynamic IP addresses and ISP restrictions
- Security headaches (exposing your home network to the internet)
For developers, this is slow, error-prone, and often impossible (especially on corporate or university networks).
Enter tunneling tools.
Modern tunneling tools like Tunnelmole automate port forwarding by creating a secure tunnel from your device to a public server, giving you a public URL with zero router config.
Meet Tunnelmole: Open Source Port Forwarding for Developers
Tunnelmole is an open source tunneling tool that makes port forwarding effortless. It’s designed for developers who need to expose local servers to the internet—without the hassle of manual network configuration.
Key features:
- Open Source: Fully transparent, optionally self-hostable, and MIT/AGPL licensed
- Free Public URLs: Instantly get a public HTTPS URL for your local port
- Custom Subdomains: Use your own subdomain (with a paid plan or self-host)
- Cross-Platform: Works on Linux, Mac, and Windows
- Native Node.js Application: Easy to install via npm or prebuilt binaries
How Tunnelmole Port Forwarding Works
Tunnelmole sets up a secure WebSocket tunnel between your device and a public Tunnelmole server. When someone accesses your public URL, the request is routed through the tunnel to your local port, and the response is sent back the same way.
Workflow:
- Start your local server (e.g., Express.js on port 3000)
- Run
tmole 3000
in your terminal - Tunnelmole gives you a public HTTPS URL (e.g.,
https://abc12.tunnelmole.net
) - Anyone can access your local server via the public URL
Installing Tunnelmole for Port Forwarding
Tunnelmole supports multiple installation methods. Choose the one that fits your workflow.
1. Install via npm (Node.js 16.10+)
sudo npm install -g tunnelmole
2. Install Precompiled Binary (Linux, Mac, WSL)
curl -O https://install.tunnelmole.com/xD345/install && sudo bash install
The script auto-detects your OS and installs the right version.
3. Windows
- Download tmole.exe
- Add it to your PATH
Port Forwarding in Action: Step-by-Step with Tunnelmole
Let’s walk through a real example: exposing a local Express.js server on port 3000.
1. Start Your Local Server
node app.js
# or
npm start
2. Forward the Port with Tunnelmole
tmole 3000
Output:
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:3000
http://cqcu2t-ip-49-185-26-79.tunnelmole.net ⟶ http://localhost:3000
Now, anyone can access your local server at the public URL.
3. Test the Public URL
Open the HTTPS URL in your browser or share it with teammates, webhook providers, or mobile devices.
Advanced Port Forwarding: Custom Subdomains & Self-Hosting
Custom Subdomains
Need a stable, memorable URL? Use a custom subdomain:
tmole 3000 as myapp.tunnelmole.net
- Hosted service: Custom subdomains require a paid plan.
- Self-host: Run your own Tunnelmole server for full control.
Learn more about self-hosting Tunnelmole
Real-World Port Forwarding Use Cases
1. Webhook Development
Test Stripe, Shopify, or Slack webhooks locally by providing a public URL to the provider.
2. Mobile & Cross-Device Testing
Access your local app from real devices on any network—no emulator required.
3. IoT Device Integration
Expose a local dashboard or API for remote IoT devices to connect and send data.
4. Remote Demos & Collaboration
Share your in-progress app with clients or teammates for instant feedback.
5. Cloud Development & CI/CD
Trigger builds, tests, or deployments from external services that require a public endpoint.
Security Considerations for Port Forwarding
Port forwarding exposes your local service to the internet. Follow these best practices:
- Use HTTPS URLs (Tunnelmole provides these by default)
- Limit exposure: Only forward ports you need, and stop the tunnel when done
- Authenticate sensitive endpoints (e.g., use API keys or OAuth)
- Monitor logs for unexpected traffic
- Self-host if you need full control over access and data
Troubleshooting Port Forwarding with Tunnelmole
Common issues:
- Port already in use: Make sure your local server is running and listening on the specified port.
- Firewall blocking traffic: Check your OS firewall settings if the tunnel isn’t working.
- No public URL shown: Ensure Tunnelmole is installed correctly and you’re using the right command.
Pro tip:
Set the environment variable TUNNELMOLE_QUIET_MODE=1
to suppress output in CI/CD scripts.
Tunnelmole vs. Traditional Port Forwarding
Feature | Tunnelmole | Traditional Port Forwarding |
---|---|---|
Open Source | ![]() |
![]() |
No Router Config | ![]() |
![]() |
Free Public URLs | ![]() |
![]() |
Custom Subdomains | ![]() |
![]() |
Self-Hostable | ![]() |
![]() |
Cross-Platform | ![]() |
![]() |
Security | HTTPS by default | Often HTTP only |
Developer Experience | CLI & npm integration | Web UI, limited automation |
Frequently Asked Questions (FAQ) About Port Forwarding
Q: Is Tunnelmole really open source?
A: Yes! Both the client and server are open source. You can self-host or use the hosted service.
Q: How do I stop port forwarding?
A: Simply stop the tmole
process in your terminal (Ctrl+C).
Summary: Port Forwarding Made Easy
Port forwarding is essential for modern development, but traditional methods are slow and complex. Tunnelmole makes port forwarding fast, secure, and developer-friendly—no router config, no headaches.
- Instantly expose any local port to the internet
- Use open source tools for transparency and control
- Share, test, and collaborate with ease
Ready to supercharge your workflow? Try Tunnelmole for your next port forwarding task.
Next Steps
Get started with secure, open source port forwarding today.
This content originally appeared on DEV Community and was authored by Robbie Cahill