What are the default ports for common databases?
BeginnerConceptDatabase connections in apps
Answer
Short answer
MySQL/MariaDB 3306, PostgreSQL 5432, MongoDB 27017, Microsoft SQL Server 1433, Oracle 1521, Redis 6379, Elasticsearch 9200, Cassandra 9042.
Table
| Database | Default port |
|---|---|
| MySQL / MariaDB | 3306 |
| PostgreSQL | 5432 |
| MongoDB | 27017 |
| SQL Server | 1433 |
| Oracle | 1521 |
| Redis | 6379 |
| Elasticsearch / OpenSearch | 9200 |
| Cassandra | 9042 |
| RabbitMQ (AMQP) | 5672 |
| Kafka | 9092 |
Why it matters
You'll open exactly these ports in security groups/NSGs — only from the app's security group or subnet, never 0.0.0.0/0 — and you'll test them with nc -zv host 5432.
What to say in the interview
"3306 MySQL, 5432 Postgres, 27017 Mongo, 1433 SQL Server, 6379 Redis. In cloud setups those ports are allowed only from the application tier's security group."
More on Database connections in apps
How does an application connect to a database, and how should connection details be passed?BeginnerAfter deployment, the app can't connect to the database. How do you troubleshoot it?IntermediateWhat is a connection string? Explain its parts.BeginnerWhy should database credentials never be stored in code or Git?BeginnerHow do Kubernetes Secrets work, and are they secure?IntermediateWhat is the External Secrets Operator?Intermediate