Open Ports and Port Forwarding

Updated

Only SSH reaches your Mac from the internet. Every other port is closed from outside, and no port is forwarded to a Mac on request. To use Screen Sharing, a web app or anything else running on the Mac, go through an SSH tunnel.

What Reaches the Mac

SSH is the one way in. The Mac’s Connect section shows its address:

  • A Mac with its own public IP takes SSH on TCP port 22, and no other port.
  • A Mac reached through Cloudflare has a mac- hostname under macmetro.com. cloudflared carries SSH over HTTPS, so a port check on that hostname reaches Cloudflare, not the Mac. See Connect Over SSH.

Why Port 5900 Looks Closed

On a Mac with a public IP, a port check from your computer shows 5900, or any port other than 22, as closed. That’s expected. The Mac still runs Screen Sharing on port 5900, but the network only lets port 22 through.

Support doesn’t open or forward incoming ports, so there’s no need to ask for 5900 or any other. Use a tunnel instead.

Reach Any Port Through SSH

An SSH tunnel carries a port on the Mac to a port on your computer. -L takes the port on your computer first, then the port on the Mac:

ssh -N -L <your port>:localhost:<Mac port> -o ExitOnForwardFailure=yes <username>@<address>

-N opens no shell, so the window looks idle. The tunnel stays open until you close it. ExitOnForwardFailure makes ssh stop with an error when the port on your computer is already taken. Tunnels carry TCP only, not UDP.

For Screen Sharing, the tunnel carries the Mac’s port 5900 to port 5901 on your computer. Then connect to localhost:5901. Screen Sharing has the steps, and the Mac’s Connect section has the command with your address filled in.

For a web app on the Mac at port 3000:

ssh -N -L 3000:localhost:3000 -o ExitOnForwardFailure=yes <username>@<address>

Then open http://localhost:3000 in your browser. For more than one port, add one -L for each.

On a Mac reached through Cloudflare, add the same ProxyCommand the Connect section’s SSH command uses:

ssh -N -L 3000:localhost:3000 -o ExitOnForwardFailure=yes -o ProxyCommand="cloudflared access ssh --hostname %h" <username>@<address>

You can also install Tailscale or another VPN on the Mac and reach its ports over your own private network.

Outgoing Ports

The Mac reaches the internet on every port except 25. Port 25 is closed outside the Enterprise plan. Send email over port 587 or 465 instead. See Sending Email and Port 25.

Need help? Email support@macmetro.com.