What is a Port?

  • A port is a virtual endpoint used for communication between devices over a network.
  • Ports help in identifying specific services running on a system.
  • Each port is associated with a protocol (TCP/UDP).

Categories of Ports

CategoryRangeDescription
1️⃣ Well-Known Ports0 - 1023Used by standard services (e.g., HTTP, SSH, DNS).
2️⃣ Registered Ports1024 - 49151Used by applications (e.g., MySQL, PostgreSQL).
3️⃣ Dynamic / Ephemeral Ports49152 - 65535Temporary ports for client connections.

Important Ports to Remember πŸ”₯

PortServiceProtocolUse Case
πŸ”’ 22SSH (Secure Shell)TCPSecure remote access to servers
🌍 80/443HTTP/HTTPSTCPWeb browsing & API requests
πŸ“¦ 20/21FTP (File Transfer Protocol)TCPTransferring files between servers
🐳 2375/2376Docker APITCPManaging Docker containers remotely
πŸ–₯️ 3389RDP (Remote Desktop Protocol)TCPAccessing Windows servers remotely
πŸ—„οΈ 27017MongoDBTCPConn to MongoDB on a remote server
🐍 3306MySQLTCPConnecting to MySQL databases
🦾 5432PostgreSQLTCPConnecting to PostgreSQL databases
πŸ“Š 9090PrometheusTCPMonitoring and metrics collection
πŸ“ˆ 3000GrafanaTCPVisualizing monitoring data
πŸ•΅οΈ 53DNS (Domain Name System)UDP/TCPResolving domain names to IPs
⏰ 123NTP (Network Time Protocol)UDPSynchronizing system time

Note

If you’re running MongoDB on a remote server, ensure port 27017 is open in your firewall or security groups.

How Ports Work?

1️⃣ A client sends a request to a server’s IP address & port. 2️⃣ The server listens on that port for incoming connections. 3️⃣ The connection is established, and data transfer begins.

TCP vs. UDP Ports

βœ… TCP (Transmission Control Protocol) – Reliable, connection-oriented (e.g., HTTPS, SSH). βœ… UDP (User Datagram Protocol) – Fast, connectionless (e.g., DNS, Streaming).

AWS Security Groups & Ports

  • Security Groups allow or deny inbound & outbound traffic based on port numbers.
  • Example:
    • Allow SSH (Port 22) β†’ Access Linux EC2 instances.
    • Allow HTTP (Port 80) β†’ Host a website on EC2.

πŸ“Œ Summary

  • Ports identify services on a system (e.g., 80 β†’ HTTP, 443 β†’ HTTPS).
  • Some ports are well-known, while others are dynamic.
  • TCP is reliable, while UDP is faster but less reliable.
  • AWS Security Groups control access using ports.