HTTPfy

Port 3306 (MySQL / MariaDB)

MySQL and MariaDB client connections.

Registered (user) port, 1024-49151 TCP Databases Do not expose to the internet

What port 3306 is used for

MySQL and MariaDB client connections.

Security: should port 3306 be open?

Do not expose to the internet. Keep it off the internet: bind to 127.0.0.1 or a private interface (bind-address) and allow only application servers in the firewall. Exposed MySQL servers face constant brute-force attempts and ransom attacks that dump and delete databases. Use TLS for connections between hosts.

IANA assignment

Service nameProtoDescriptionAssigneeReference
mysql TCP MySQL Monty -
mysql UDP MySQL Monty -

Check what is listening on port 3306

Linux: is anything listening on TCP 3306?
sudo ss -tlnp 'sport = :3306'
Linux / macOS: which process owns the port
sudo lsof -nP -i :3306
Older Linux / BSD (net-tools)
sudo netstat -tlnp | grep ':3306 '
Windows (Command Prompt)
netstat -ano | findstr :3306
Windows (PowerShell)
Get-NetTCPConnection -LocalPort 3306 -State Listen | Select LocalAddress,OwningProcess

Test it from outside

From another machine
nc -vz -w 5 HOST 3306
From Windows
Test-NetConnection HOST -Port 3306

Block port 3306 in the firewall

ufw
sudo ufw deny 3306/tcp
iptables
sudo iptables -A INPUT -p tcp --dport 3306 -j DROP
nftables
sudo nft add rule inet filter input tcp dport 3306 drop
Windows Firewall
New-NetFirewallRule -DisplayName 'Block TCP 3306' -Direction Inbound -Protocol TCP -LocalPort 3306 -Action Block

Related ports

All port numbers · Open port checker
Assignment data: IANA port number registry (public domain), retrieved 2026-11-10.