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."

All Build Tools (Java, Node.js, Python, .NET) questions Roadmap: Connecting apps to databases

More on Database connections in apps