Expose databases, SSH, and other TCP services to the internet securely
TCP tunneling allows you to expose any TCP-based service through stunl. Perfect for databases (PostgreSQL, MySQL, MongoDB, Redis), SSH access, game servers, and custom TCP protocols.
Included in Pro
TCP tunneling is included in all Pro accounts. Start free.
# Expose PostgreSQL (port 5432)
$ stunl -protocol tcp -port 5432 -id mydb
● STUNL
╭── ⇄ ── TCP mydb
│ Connect mydb.stunl.io:15432
│ Local localhost:5432
# Connect from anywhere:
$ psql -h mydb.stunl.io -p 15432 -U postgres
# Create tunnel
$ stunl -protocol tcp -port 5432 -id mydb
# Connect with psql
$ psql -h mydb.stunl.io -p 15432 -U myuser -d mydb
# Connection string
postgresql://myuser:mypass@mydb.stunl.io:15432/mydb
# Create tunnel
$ stunl -protocol tcp -port 3306 -id mysql
# Connect with mysql client
$ mysql -h mysql.stunl.io -P 13306 -u root -p
# Connection string
mysql://root:password@mysql.stunl.io:13306/mydb
# Create tunnel
$ stunl -protocol tcp -port 6379 -id redis
# Connect with redis-cli
$ redis-cli -h redis.stunl.io -p 16379
# Connection string
redis://redis.stunl.io:16379
# Create tunnel
$ stunl -protocol tcp -port 27017 -id mongo
# Connect with mongosh
$ mongosh "mongodb://mongo.stunl.io:17017/mydb"
# Connection string
mongodb://mongo.stunl.io:17017/mydb
By default, TCP tunnels are assigned random public ports (10001-19999) that change each time you reconnect. With reserved ports, you lock in a specific port number that persists across reconnects.
# First, reserve a port at portal.stunl.com
# Then use the -public-port flag:
$ stunl -protocol tcp -port 5432 -id mydb -public-port 15432
● STUNL
╭── ⇄ ── TCP mydb
│ Connect mydb.stunl.io:15432 ← Always the same!
│ Local localhost:5432
Why Reserve Ports?
Pro includes 2 reserved ports free (max 10). Reserve ports at portal.stunl.com.
Combine HTTP and multiple TCP services in a single tunnel using the -ports flag.
$ stunl -id myapp -ports "web:3000:http,db:5432:tcp,cache:6379:tcp"
● STUNL
╭── ◎ ── HTTP web
│ HTTPS https://myapp.stunl.io
│ Local localhost:3000
╭── ⇄ ── TCP db
│ Connect myapp.stunl.io:15432
│ Local localhost:5432
╭── ⇄ ── TCP cache
│ Connect myapp.stunl.io:16379
│ Local localhost:6379
# With reserved ports:
$ stunl -id myapp -ports "web:3000:http,db:5432:tcp@15432,cache:6379:tcp@16379"
stunl also supports UDP tunneling for game servers, VoIP, and real-time applications.
# Expose Minecraft server (UDP port 25565)
$ stunl -protocol udp -port 25565 -id minecraft
● STUNL
╭── ◇ ── UDP minecraft
│ Connect minecraft.stunl.io:10001
│ Local localhost:25565
| Feature | Pro |
|---|---|
| Total tunnels (HTTP/TCP/UDP) | 10 |
| Reserved ports included | 2 |
| Max reserved ports | 10 |
⚠️ Security Best Practices