Beta Docs Sign inGet started

Your server needs no open port

November 25, 2026

Every open port is a door. Bots knock on all of them, all day. A fresh VPS sees its first SSH login attempts within minutes.

The safest door is the one that is not there. Most servers can close every inbound port and lose nothing.

Inbound and outbound

A connection has a direction. Inbound: someone out there connects to your server. Outbound: your server connects out.

A firewall can block every inbound connection and still let your server reach out. Outbound is how it pulls images, sends mail and talks to its backups. Nobody can start a conversation with a server that only dials out.

Step 1: SSH without port 22

Tailscale puts your laptop and your server in one private network. Both dial out to Tailscale, so no port opens.

curl -fsSL https://tailscale.com/install.sh | sh
tailscale up --ssh

--ssh turns on Tailscale SSH. Now ssh root@server-1 works from your laptop, over the private network. Keys and access live in your Tailscale admin, not in authorized_keys.

Check it works before the next step. Otherwise you lock yourself out.

Step 2: close the doors

ufw default deny incoming
ufw default allow outgoing
ufw allow in on tailscale0
ufw enable

Every inbound port is closed now. Only the Tailscale network gets in.

Most providers also have a firewall in front of the server, like Hetzner’s Cloud Firewall. Use it as a second lock: no inbound rule at all.

Step 3: visitors without port 80 and 443

Your apps still need visitors. A Cloudflare Tunnel does it the same way: cloudflared on your server dials out to Cloudflare, and Cloudflare sends the visitors through that connection.

services:
  tunnel:
    image: cloudflare/cloudflared:latest
    command: tunnel --no-autoupdate run
    environment:
      TUNNEL_TOKEN: ${TUNNEL_TOKEN}

You get the token in the Cloudflare dashboard, under Zero Trust, Networks, Tunnels. There you also say which hostname goes to which container.

Don’t want Cloudflare in the middle? Then open 80 and 443, and only those. They are the doors meant for the public.

The trap: Docker skips your firewall

This one surprises people. A port you publish in Docker, like ports: "5432:5432", is open to the internet even with ufw on. Docker writes its own iptables rules, and they come before ufw’s.

So publish to localhost only:

ports:
  - "127.0.0.1:5432:5432"

Or don’t publish at all. Containers in one compose file reach each other by name, like db:5432, without any port.

What you end up with

  • No port 22. SSH over Tailscale.
  • No database port. Containers talk inside Docker.
  • No port for your tools. They dial out.
  • Port 80 and 443 only if you don’t use a tunnel.

How moin does it

moin itself needs no open port: it comes in over your SSH, and reports go out. Soon moin does these steps for you too. After the first deploy it will close public SSH, so you reach the server only over Tailscale. moin secure my-server will add the Cloudflare Tunnel and the firewall.

Security has the whole picture.

From the blog.

Short posts on running your own apps.

See all

Deploy anything.
Lose nothing.

curl -fsSL https://moin.run/cli.sh | sh

30 days free. No card.