Database Ports: MySQL, PostgreSQL, MongoDB, Redis, and More

Reference guide for all major database port numbers. MySQL 3306, PostgreSQL 5432, MongoDB 27017, Redis 6379, and more with security best practices.

Databases

Detailed Explanation

Database Port Numbers

Databases use specific ports for client connections. Knowing these ports is critical for connection configuration, firewall rules, and security hardening.

Relational Databases

Database Port Protocol
MySQL / MariaDB 3306 TCP
PostgreSQL 5432 TCP
Microsoft SQL Server 1433 TCP
Oracle Database 1521 TCP

NoSQL Databases

Database Port Protocol
MongoDB 27017 TCP
Redis 6379 TCP
Cassandra (CQL) 9042 TCP
CouchDB 5984 TCP
Neo4j (Bolt) 7687 TCP
RethinkDB 28015 TCP

In-Memory Stores

Service Port Protocol
Redis 6379 TCP
Memcached 11211 TCP/UDP

Security Best Practices

  1. Never expose database ports to the public internet. Use VPNs or SSH tunnels for remote access.
  2. Change default ports when possible to reduce automated scanning attacks.
  3. Use TLS connections — Redis supports TLS on port 6380, MySQL supports TLS on the default port.
  4. Restrict access by IP in firewall rules to only allow connections from application servers.
# Allow MySQL only from app server
iptables -A INPUT -p tcp --dport 3306 -s 10.0.1.100 -j ACCEPT
iptables -A INPUT -p tcp --dport 3306 -j DROP

Use Case

Configuring a production database server with strict firewall rules that only allow connections from known application servers on the correct database ports.

Try It — Port Number Reference

Open full tool