What is port 3306 used for?
The default MySQL and MariaDB database port.
Should port 3306 be open?
Don’t expose to the internet. Keep this port on private networks and reach it through a VPN or SSH tunnel. Bind MySQL to 127.0.0.1 or a private IP and connect remotely through an SSH tunnel.
See what is listening on port 3306
# Linux
sudo ss -tlnp | grep ':3306 '
# macOS
sudo lsof -nP -i TCP:3306 -sTCP:LISTEN
# Windows (PowerShell)
Get-NetTCPConnection -LocalPort 3306 -State Listen
Open or block port 3306 in a firewall
# Ubuntu / Debian (ufw)
sudo ufw allow 3306/tcp
sudo ufw deny 3306/tcp
# Windows (PowerShell, as administrator)
New-NetFirewallRule -DisplayName "Port 3306" -Direction Inbound -Protocol TCP -LocalPort 3306 -Action Allow
On cloud servers, also open the port in the provider’s security group or network firewall. At home, a service behind a router needs a port-forwarding rule to the device’s local IP.
Test it from outside
A port can be open on the server but blocked upstream. The Port Checker connects from the internet, so it shows what the world sees. From your own machine, use nc -vz example.com 3306 (macOS/Linux) or Test-NetConnection example.com -Port 3306 (Windows).