When port forwarding is appropriate and when it is not
Published on 2026-09-12 by frfrand
A short guide to deciding between opening a port, setting up a reverse proxy, or establishing a tunnel, and the question that resolves ninety percent of cases.

Short answer: open a port only if the service needs to be available to the world, such as a website, a public API, or a mail server. If only you or your team use it (a database, an admin panel), don't open it: use an SSH tunnel or a private network. And if you still have to open it, limit the source and note why.
Almost every time someone asks "how do I open this port?", the correct answer is "probably don't open it".
Not out of paranoia. Because opening a port is a decision that costs little today and a lot over the next few years, and there are alternatives that solve the same thing without that pending account.
The question that orders everything
Before touching the firewall, answer one thing:
Does this need to be available to the world, or only to you and your team?
If the answer is "to the world", you need to expose it, and it's worth doing it right. If the answer is "for us", don't open anything: use a tunnel.
It sounds simple because it is. The problem is that the first time you need to connect to the database from home, opening the port seems like the fastest option. And then it stays open.
What happens when you open a port
It's not a metaphor: put a new service on a public IP and check the logs in two hours.
There are entire networks dedicated to scanning the entire Internet address space, all the time. They didn't choose you: they sweep everything. An open port appears on their lists in minutes.
That doesn't mean they will get in. It means that from that moment on, the security of that service depends entirely on how well it is configured, its version, and that you apply the patches. Forever.
For a web server that is acceptable: it is its job. For a database or an administration panel, it is almost never worth it.
The three cases where it is
A truly public service. A website, an API consumed by third parties, a mail server. It is its reason for existing.
A protocol that is not HTTP and needs direct access. Games, some messaging systems, devices that don't know how to do anything else.
An incoming webhook. An external service needs to hit your door. Here it is worth clarifying something: a webhook comes in via HTTPS, so you don't need to open a new port. It comes in through port 443 that you already have, and your reverse proxy routes it.
And the cases where it is almost never
Databases. PostgreSQL, MySQL, Redis, Mongo. If your application lives on the same server, the database does not need to go out to the network at all. If it lives on another server, use an internal network or a tunnel between the two.
Administration panels. phpMyAdmin, Adminer, your framework's panel. They are classic targets precisely because many people leave them open.
Anything "temporary". There is no such thing as a temporary port. There is the port you opened and didn't close.
The concrete alternative
ssh -L 5432:localhost:5432 prod
With that, port 5432 on the server appears on your machine as if it were local. Your client connects to localhost, the traffic is encrypted via SSH, and the server has no database port exposed.
If the connection drops when you change networks, autossh reconnects it automatically.
And for an entire team, the scaled version of the same idea is a VPN or a Tailscale-type network: machines see each other as if they were in the same office, without any of them having a port open to the world.
If you still have to open
Three minimums that change the risk a lot:
- Limit by origin. If only your office enters, allow only that address. Most firewalls allow this in one line.
- Put something in front. A reverse proxy with request limiting absorbs most of the noise.
- Note why you opened it and when to review it. Open ports without an owner are the ones that survive for years.
In ArduMaker, from the Internet to a VPS only what you declare enters (a published domain or a port forwarding), precisely so that opening is a decision and not an oversight; and each forwarding can be limited by source IP, which by default remains open to everyone. For internal use there are SSH tunnels between VPS: the database does not publish its port and traffic between your servers travels encrypted.
Three questions before opening a port
Should the service be available to anyone or only to your team? Does it need HTTPS and a domain name? Could you use an authenticated tunnel instead of exposing the service?
On an ArduMaker VPS, a public website usually enters through port 443 and reaches the application via Nginx. An administrative console or database usually requires different treatment. Check the firewall after every deployment to avoid a temporary port becoming permanent.
Related: Port forwarding · Tailscale.
Frequently asked questions
Does a webhook require opening a new port? No. It arrives via HTTPS on port 443, which you already have published, and your reverse proxy forwards it to the corresponding application.
My database lives on another server, do I have to expose it? No. Use an internal network or a tunnel between the two servers; the database port does not have to be public.
What do I do if the SSH tunnel drops when I change networks? autossh brings it back up automatically. For an entire machine, a VPN or a Tailscale-type network is recommended.