Перейти к содержимому
Skip to content
← All articles

Open Server Ports: How to Check and Why It Matters for Security

Network ports are virtual entry points through which applications on a server accept network connections. Every open port is a potential attack vector. Understanding which ports are open on your server and why is the foundation of network security.

How Network Ports Work

An IP address identifies a server on the network, while a port identifies a specific application on that server. Together they form a socket, e.g., 93.184.216.34:443. There are 65,535 total ports, divided into three ranges:

RangeNameDescription
0–1023Well-known portsReserved for standard services (HTTP, SSL/TLS проверку, SSH, FTP)
1024–49151Registered portsAssigned to specific applications (MySQL, PostgreSQL, Redis)
49152–65535Dynamic portsUsed for temporary connections

Common Ports and Services

PortProtocolServiceShould Be Public?
22TCPSSHOnly with IP restrictions
25TCPSMTPOnly for mail servers
53TCP/UDPDNSOnly for DNS servers
80TCPHTTPYes (redirect to HTTPS)
443TCPHTTPSYes
3306TCPMySQLNo — localhost only
5432TCPPostgreSQLNo — localhost only
6379TCPRedisNo — localhost only
8080TCPHTTP alternativeDepends on use case
27017TCPMongoDBNo — localhost only

Why Open Ports Are Dangerous

Expanded Attack Surface

Every open port runs a service that may contain vulnerabilities. More open ports mean more potential entry points for an attacker.

Common Port-Based Attacks

How to Check Open Ports

From Inside the Server

# All listening ports
ss -tlnp
# or
netstat -tlnp

# Specific port
ss -tlnp | grep :3306

From Outside (Scanning)

# nmap — scan common ports
nmap example.com

# Specific ports
nmap -p 22,80,443,3306,6379 example.com

# Service version detection
nmap -sV example.com

Online Tools

For quick checks without installing nmap, use online port checking tools. Enterno.io provides a Ping tool with TCP port checking capabilities.

How to Secure Open Ports

1. Firewall (iptables / ufw / firewalld)

The primary defense tool is a firewall. Principle: deny everything, allow only what's necessary.

# UFW (Ubuntu)
ufw default deny incoming
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow from 1.2.3.4 to any port 22   # SSH from your IP only
ufw enable

2. Bind to localhost

Services that don't need external access should listen only on 127.0.0.1:

# MySQL: my.cnf
bind-address = 127.0.0.1

# Redis: redis.conf
bind 127.0.0.1

# PostgreSQL: postgresql.conf
listen_addresses = 'localhost'

3. Change Default Ports

Changing the SSH port from 22 to a non-standard one (e.g., 2222) isn't true security, but it significantly reduces automated attack noise.

4. Fail2ban

Fail2ban monitors logs and blocks IPs after repeated failed connection attempts:

# Install
apt install fail2ban

# Check status
fail2ban-client status sshd

5. VPN / SSH Tunnels

For admin interfaces (control panels, databases, monitoring dashboards), use VPN or SSH tunnels instead of exposing ports to the internet.

Port Security Checklist

Check your website right now

Check now →
More articles: Security
Security
Rate Limiting Strategies for Web APIs and Applications
16.03.2026 · 10 views
Security
WAF: What It Is and How It Protects Your Site
14.03.2026 · 13 views
Security
Security Headers: The Complete Guide
14.03.2026 · 16 views
Security
Web Server Security Hardening Checklist: Nginx and Apache
16.03.2026 · 30 views