What port does MySQL use?
MySQL uses port 3306 over TCP.
| Port | Protocol | Name | What it is for |
|---|---|---|---|
| 3306 | TCP | MySQL / MariaDB | The default MySQL and MariaDB port. |
Exposing it
Bind to 127.0.0.1 unless a remote application genuinely needs it, and then restrict by source address. Internet-exposed MySQL is scanned constantly.
Checking it is listening
sudo lsof -i :3306 # macOS, Linux
netstat -ano | findstr :3306 # Windows
nc -zv host 3306 # from elsewhere
An "address already in use" error on a port nothing appears to be holding usually means the socket is in TIME_WAIT rather than that a process has it — the ports reference covers that and the ephemeral range.
Frequently asked questions
What port does MySQL use?
MySQL uses port 3306 over TCP. The default MySQL and MariaDB port.
Is port 3306 safe to expose to the internet?
Bind to 127.0.0.1 unless a remote application genuinely needs it, and then restrict by source address. Internet-exposed MySQL is scanned constantly.
How do I check whether MySQL is listening?
sudo lsof -i :3306 on macOS or Linux, netstat -ano | findstr :3306 on Windows. From another machine, nc -zv host 3306 says whether anything answers.
Other services
- What port does PostgreSQL use?
- What port does SQL Server use?
- What port does Oracle use?
- What port does MongoDB use?
- What port does Redis use?
- What port does Memcached use?
- What port does Elasticsearch use?
- What port does DNS use?
- What port does NTP use?
- What port does SMB use?
- What port does NFS use?
- What port does SNMP use?