> Expose databases, game servers, SSH, Redis, and any TCP service to the internet with a dedicated port. Available on all plans.

# TCP Tunnels

TCP tunnels let you expose any TCP-based service to the internet. Databases, game servers, SSH, Redis, MQTT, custom binary protocols — if it speaks TCP, Localport can tunnel it. And unlike some alternatives, TCP tunnels are available on every plan.

## Basic usage

```bash
localport tcp 5432 --token YOUR_TOKEN
```

Localport allocates a dedicated port on the edge — something like `abc123.tunnel.localport.dev:47266` — and prints it in the status panel. Any TCP connection to that address is forwarded straight to your local service.

## Connecting to your tunneled service

Use the tunnel address from anywhere in the world:

```bash
# PostgreSQL
psql -h abc123.tunnel.localport.dev -p 47266 -U myuser mydb

# MySQL
mysql -h abc123.tunnel.localport.dev -P 47266 -u myuser -p

# Redis
redis-cli -h abc123.tunnel.localport.dev -p 47266

# SSH
ssh user@abc123.tunnel.localport.dev -p 47266

# Minecraft — give this address to friends
abc123.tunnel.localport.dev:47266
```

## TLS passthrough

If your service handles its own TLS termination (like a production HTTPS server or a TLS-wrapped database), use TLS mode. Localport passes the encrypted bytes through without decrypting:

```bash
localport tls 443 --token YOUR_TOKEN
```

## Reserved ports

On any plan, you can reserve a specific port from the dashboard. This means your game server or database always gets the same port number, even after restarting the tunnel.

> [!TIP] Stable addresses matter
> If you're sharing a game server address with friends or configuring a remote database connection, a reserved port means the address never changes.

## How it works

1. You start a TCP tunnel, and the edge server picks an available port from its pool
2. A dedicated listener opens on that port
3. External connections to that port get forwarded to your CLI
4. Your CLI proxies them to your local service
5. Raw TCP bytes flow both directions — zero protocol overhead after the initial handshake

## Common use cases

- **Game servers** — Minecraft, Valheim, Terraria, Factorio. [Full game server guide](/docs/game-servers)
- **Database access** — Let a remote app or teammate connect to your local Postgres, MySQL, or Redis
- **SSH access** — Get into your home machine or server from anywhere without a VPN
- **Home automation** — Access Home Assistant, OctoPrint, or Pi-hole remotely. [Homelab guide](/docs/homelab)
- **Custom protocols** — MQTT, gRPC, proprietary binary protocols — anything TCP

## Next steps

- [Mesh Tunnels](/docs/mesh-tunnels) — Give each device in a fleet its own address
- [Game Servers](/docs/game-servers) — Detailed setup for Minecraft, Valheim, and more
- [Homelab Remote Access](/docs/homelab) — Tunnel your self-hosted services