keecode logokeecode
Networking
port numbers
network ports
http port
https port
ssh port
common ports
tcp ports

Common Port Numbers for Developers - Complete Reference

Complete reference for common network port numbers. Learn about HTTP, HTTPS, SSH, FTP, database ports, and more essential ports for web development.

Updated January 15, 2025

Port numbers are essential for network communication, allowing multiple services to run on the same server. This guide covers the most important port numbers every developer should know.

Table of Contents

  1. What Are Port Numbers?
  2. Port Number Ranges
  3. Common Web Ports
  4. Database Ports
  5. Development Server Ports
  6. Security Considerations
  7. Troubleshooting Port Issues

What Are Port Numbers?

Port numbers are 16-bit unsigned integers (0-65535) that identify specific processes or services on a networked computer. They work like apartment numbers in a building - the IP address is the street address, and the port number is the specific apartment.

Format: IP:Port

Examples:

  • 192.168.1.1:80 - HTTP web server
  • example.com:443 - HTTPS secure website
  • localhost:3000 - Development server

Why Ports Matter

  • Multiple Services: Run web server (80), database (3306), and SSH (22) on same server
  • Security: Block or allow specific services through firewall rules
  • Development: Test multiple applications simultaneously
  • Debugging: Identify which service is causing issues

Port Number Ranges

Ports are divided into three categories:

rangecategoryusageexamples
0-1023Well-Known PortsSystem/Standard servicesHTTP (80), HTTPS (443), SSH (22)
1024-49151Registered PortsUser/Application servicesMySQL (3306), PostgreSQL (5432)
49152-65535Dynamic/Private PortsTemporary/Private useRandomly assigned by OS

Well-Known Ports (0-1023)

Reserved for standard services. Require administrative/root privileges to bind.

Registered Ports (1024-49151)

Registered with IANA for specific services. Can be used by normal users.

Dynamic/Private Ports (49152-65535)

Temporary ports assigned by the operating system for client connections.

Common Web Ports

HTTP - Port 80

Protocol: HTTP
Use: Standard web traffic (unencrypted)
Default: Yes (browsers assume :80 for http://)

# Access website on port 80
http://example.com
http://example.com:80  # Explicit port (same as above)

# Start web server
python -m http.server 80  # Requires sudo/admin
node server.js --port 80

View Port 80 details

HTTPS - Port 443

Protocol: HTTPS
Use: Secure web traffic (encrypted)
Default: Yes (browsers assume :443 for https://)

# Access secure website
https://example.com
https://example.com:443  # Explicit port

# Nginx HTTPS config
server {
    listen 443 ssl;
    server_name example.com;
    ssl_certificate /path/to/cert.pem;
    ssl_certificate_key /path/to/key.pem;
}

View Port 443 details

SSH - Port 22

Protocol: SSH (Secure Shell)
Use: Remote server access, file transfers (SFTP)
Security: Encrypted connection

# Connect via SSH
ssh user@example.com
ssh user@example.com -p 22  # Explicit port

# Custom port (more secure)
ssh user@example.com -p 2222

# SFTP (file transfer over SSH)
sftp user@example.com

View Port 22 details

FTP - Ports 20, 21

Protocol: FTP (File Transfer Protocol)
Ports: 21 (control), 20 (data)
Use: File transfers
Security: ⚠️ Not encrypted (use SFTP or FTPS instead)

# FTP connection (insecure)
ftp example.com

# FTPS (FTP over SSL) - Port 990
ftps example.com 990

DNS - Port 53

Protocol: DNS (Domain Name System)
Use: Domain name resolution
Transport: UDP (primarily), TCP (for large responses)

# Query DNS
nslookup example.com
dig example.com @8.8.8.8

SMTP - Port 25, 587, 465

Protocol: SMTP (Simple Mail Transfer Protocol)
Ports:

  • 25: Standard SMTP (often blocked by ISPs)
  • 587: SMTP with STARTTLS (recommended)
  • 465: SMTPS (SMTP over SSL)
// Node.js email with nodemailer
const nodemailer = require('nodemailer');

const transporter = nodemailer.createTransport({
  host: 'smtp.gmail.com',
  port: 587,  // STARTTLS
  secure: false,
  auth: {
    user: 'your-email@gmail.com',
    pass: 'your-password'
  }
});

IMAP - Port 143, 993

Protocol: IMAP (Internet Message Access Protocol)
Ports:

  • 143: IMAP (unencrypted)
  • 993: IMAPS (IMAP over SSL)

POP3 - Port 110, 995

Protocol: POP3 (Post Office Protocol)
Ports:

  • 110: POP3 (unencrypted)
  • 995: POP3S (POP3 over SSL)

Database Ports

MySQL/MariaDB - Port 3306

# Connect to MySQL
mysql -h localhost -P 3306 -u root -p

# Connection string
mysql://user:password@localhost:3306/database
// Node.js MySQL connection
const mysql = require('mysql2');

const connection = mysql.createConnection({
  host: 'localhost',
  port: 3306,
  user: 'root',
  password: 'password',
  database: 'mydb'
});

PostgreSQL - Port 5432

# Connect to PostgreSQL
psql -h localhost -p 5432 -U postgres

# Connection string
postgresql://user:password@localhost:5432/database

MongoDB - Port 27017

# Connect to MongoDB
mongo mongodb://localhost:27017

# With authentication
mongo mongodb://user:password@localhost:27017/database
// Node.js MongoDB connection
const { MongoClient } = require('mongodb');

const client = new MongoClient('mongodb://localhost:27017');
await client.connect();
const db = client.db('mydb');

Redis - Port 6379

# Connect to Redis
redis-cli -h localhost -p 6379

# With password
redis-cli -h localhost -p 6379 -a password

Microsoft SQL Server - Port 1433

# Connection string
Server=localhost,1433;Database=mydb;User Id=sa;Password=password;

Oracle Database - Port 1521

# Connection string
sqlplus user/password@localhost:1521/ORCL

Development Server Ports

Node.js / Express - Port 3000

const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;

app.get('/', (req, res) => {
  res.send('Hello World');
});

app.listen(PORT, () => {
  console.log(\`Server running on http://localhost:\${PORT}\`);
});

React - Port 3000

# Default React development server
npm start
# Runs on http://localhost:3000

# Custom port
PORT=3001 npm start

Vue.js - Port 8080

# Default Vue development server
npm run serve
# Runs on http://localhost:8080

Angular - Port 4200

# Default Angular development server
ng serve
# Runs on http://localhost:4200

# Custom port
ng serve --port 4201

Next.js - Port 3000

# Default Next.js development server
npm run dev
# Runs on http://localhost:3000

# Custom port
npm run dev -- -p 3001

Python Flask - Port 5000

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello():
    return 'Hello World'

if __name__ == '__main__':
    app.run(port=5000, debug=True)
    # Runs on http://localhost:5000

Django - Port 8000

# Default Django development server
python manage.py runserver
# Runs on http://localhost:8000

# Custom port
python manage.py runserver 8080

Ruby on Rails - Port 3000

# Default Rails server
rails server
# Runs on http://localhost:3000

# Custom port
rails server -p 3001

PHP Built-in Server - Port 8000

# PHP development server
php -S localhost:8000
# Runs on http://localhost:8000

Common Port Conflicts

When Ports Are Already in Use

# Error message
Error: listen EADDRINUSE: address already in use :::3000

# Find what's using the port (Unix/Mac)
lsof -i :3000
netstat -an | grep 3000

# Find what's using the port (Windows)
netstat -ano | findstr :3000

# Kill process on port (Unix/Mac)
kill -9 $(lsof -t -i:3000)

# Kill process on port (Windows)
taskkill /PID <process_id> /F

Running Multiple Servers

# Frontend on 3000
npm start

# Backend on 3001
node server.js --port 3001

# Database on 5432 (PostgreSQL)
# Redis on 6379

# Everything running simultaneously
Frontend:  http://localhost:3000
Backend:   http://localhost:3001
Database:  postgresql://localhost:5432
Redis:     redis://localhost:6379

Security Considerations

Block Unused Ports

# Firewall rules (UFW - Ubuntu)
sudo ufw allow 80/tcp    # HTTP
sudo ufw allow 443/tcp   # HTTPS
sudo ufw allow 22/tcp    # SSH

sudo ufw deny 3306/tcp   # Block external MySQL access
sudo ufw deny 27017/tcp  # Block external MongoDB access

sudo ufw enable

Change Default Ports

# /etc/ssh/sshd_config
Port 2222  # Change from default 22

# Restart SSH service
sudo systemctl restart sshd

# Connect with new port
ssh user@example.com -p 2222

Database Security

# Only allow localhost connections
# MySQL config
bind-address = 127.0.0.1

# PostgreSQL pg_hba.conf
host    all    all    127.0.0.1/32    md5

# Use SSH tunneling for remote database access
ssh -L 3306:localhost:3306 user@remote-server
# Now connect to localhost:3306 on your machine

Port Forwarding

SSH Tunnel

# Forward remote port to local
ssh -L local_port:localhost:remote_port user@server

# Example: Access remote MySQL locally
ssh -L 3306:localhost:3306 user@example.com
# Then connect to localhost:3306

# Forward local port to remote
ssh -R remote_port:localhost:local_port user@server

Nginx Reverse Proxy

# Forward traffic from port 80 to 3000
server {
    listen 80;
    server_name example.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Complete Port Reference

Most Common Ports

PortProtocolServiceSecurity
20FTPFTP Data⚠️ Insecure
21FTPFTP Control⚠️ Insecure
22SSHSecure Shell✅ Secure
23TelnetRemote Terminal⚠️ Insecure
25SMTPEmail (Send)⚠️ Unencrypted
53DNSDomain Resolution✅ Essential
80HTTPWeb Traffic⚠️ Unencrypted
110POP3Email (Receive)⚠️ Unencrypted
143IMAPEmail (Receive)⚠️ Unencrypted
443HTTPSSecure Web✅ Secure
465SMTPSSecure Email✅ Secure
587SMTPEmail with TLS✅ Secure
993IMAPSSecure Email✅ Secure
995POP3SSecure Email✅ Secure
1433MS SQLSQL Server⚠️ Secure connection
1521OracleOracle DB⚠️ Secure connection
3000CustomNode.js/React🔧 Development
3306MySQLMySQL/MariaDB⚠️ Secure connection
4200CustomAngular🔧 Development
5000CustomFlask🔧 Development
5432PostgreSQLPostgreSQL⚠️ Secure connection
6379RedisRedis Cache⚠️ Secure connection
8000CustomDjango/PHP🔧 Development
8080HTTPAlt Web/Vue🔧 Development
8443HTTPSAlt Secure Web✅ Secure
27017MongoDBMongoDB⚠️ Secure connection

Summary

Understanding port numbers is essential for web development, server configuration, and network troubleshooting. Always use secure protocols (HTTPS, SSH, SFTP) and block unnecessary ports.

Key Takeaways:

✅ Port 80 for HTTP, 443 for HTTPS
✅ Port 22 for SSH remote access
✅ Port 3306 for MySQL, 5432 for PostgreSQL
✅ Development servers: 3000 (Node/React), 8000 (Django), 5000 (Flask)
✅ Always use encrypted connections (HTTPS, SSH, not FTP)
✅ Block database ports from external access
✅ Change default SSH port (22) for better security
✅ Use firewall rules to control port access