Skip to content
VDS · Network, IP address and domains

Ports: which to open and how to check

Which ports typical services need, how to see what the machine is listening on, how to check external availability, and what to do if a port is closed.

Updated August 23, 2026

A port is a number that tells the system which service should receive an incoming connection. The rule is simple: only what you actually use should be open. Every extra open port is another door that someone will test for weaknesses.

Common port numbers

PortServiceOpen to the outside
22SSHYes, preferably restricted by address
80HTTPYes, if you have a website
443HTTPSYes, if you have a website
25, 465, 587MailInbound — only if you run your own mail server. Outbound is closed on our side and opened on request
3306MySQLNo, local only
5432PostgreSQLNo, local only
6379RedisNo, local only
27017MongoDBNo, local only
25565MinecraftYes, if it's a game server

A note on mail: inbound connections are not restricted, while outbound connections on 25, 465, and 587 are closed at the node level until you ask us to open them. Rules inside the machine do not change this — see Mail server: why it's hard and what to consider for details.

Databases are almost never exposed to the outside. If you need access from your work computer, the right way is an SSH tunnel, not an open port:

ssh -L 5432:127.0.0.1:5432 artem@<address>

What the machine is listening on

ss -tulpn
ss -tlpn | grep 443
lsof -i -P -n | grep LISTEN

Look at the address before the port number. 127.0.0.1:5432 means the service is only available from inside — it isn't reachable from outside, no matter how many rules you add. 0.0.0.0:5432 means the service is open on all network interfaces and must be protected by a firewall.

Checking from the outside

From your computer:

nc -vz <address> 443
curl -I http://<address>

Checking with ping is pointless: ICMP and TCP are different things; a port can work while ping is blocked, and vice versa.

Port is closed: step-by-step troubleshooting

  1. Is the service running? systemctl status <service>
  2. Is it listening on the right address? ss -tulpn — not 127.0.0.1
  3. Does the firewall allow it? ufw status verbose or nft list ruleset
  4. Is Docker interfering? Published container ports bypass ufw
  5. Check the service logs: journalctl -u <service> -n 50

The order matters: most often the problem is at step two, not in the firewall.

Changing a service port

For example, moving SSH:

sed -i "s/^#\?Port 22/Port 2222/" /etc/ssh/sshd_config
ufw allow 2222/tcp
sshd -t
systemctl restart ssh

Check that you can log in on the new port in a separate window, and only then remove the rule for port 22. For details, see SSH hardening.

Common mistakes

SymptomCauseSolution
Connection refusedService is not runningsystemctl status, check the logs
Connection timed outPacket is dropped by the firewallCheck the rules
Works locally, not from outsideBound to 127.0.0.1Change the address in the config
Address already in usePort is taken by another servicess -tulpn and stop the extra service

Open a port only after checking what is answering on it. A forgotten port from an old experiment is a typical entry point for a hack; see signs of compromise.