Skip to main content
⚡ OpenDevDocs
Fundamentals
fundamentalsnetworkingGuideBeginner

Network Ports and Sockets

Understanding network ports, socket endpoints, standard port allocations (80, 443, 3000, 5432), and resolving port collisions.

Verified: 2026-09-30
Platforms:
all
#ports#networking#sockets#dev-server#fundamentals

Network Ports and Sockets

While an IP address identifies a specific machine on a network, a port number identifies a specific application or process running on that machine. The combination of an IP address and a port number forms a network socket (e.g. 127.0.0.1:3000).


1. How Ports Work

Think of the IP address as an apartment building's street address, and the port number as an individual apartment unit number. Multiple services can run on a single machine simultaneously as long as each listens on a unique port.

                  [ Single Server IP: 192.168.1.50 ]
                  ┌─────────────────────────────────┐
  Web Traffic  ──►│ Port 80 / 443  ──► Nginx        │
  PostgreSQL   ──►│ Port 5432      ──► Postgres DB  │
  Redis Cache  ──►│ Port 6379      ──► Redis        │
  SSH Remote   ──►│ Port 22        ──► OpenSSH      │
                  └─────────────────────────────────┘

2. Port Ranges and Classifications

Ports are 16-bit unsigned integers ranging from 0 to 65535, divided into three categories:

RangeNameDescription
0 – 1023Well-Known PortsReserved for system services and standard protocols. Requires root/administrator privileges to bind on Linux/macOS.
1024 – 49151Registered PortsAssigned by IANA for specific developer services, databases, and application frameworks.
49152 – 65535Dynamic / Ephemeral PortsAssigned temporarily by the OS for outbound client connections.

3. Common Standard Ports for Developers

PortServiceDescription
22SSHSecure Shell for remote server terminal access.
80HTTPStandard unencrypted web traffic.
443HTTPSStandard TLS-encrypted web traffic.
3000Node / Next.jsCommon default for Next.js, React, and Express dev servers.
3306MySQLDefault MySQL / MariaDB database port.
5432PostgreSQLDefault PostgreSQL database port.
6379RedisDefault in-memory cache port.
8080HTTP AlternateFrequently used for secondary dev web servers or Tomcat/Spring.

4. Inspecting and Freeing Occupied Ports

If two applications attempt to bind to the same port at the same time, the second process will crash with an EADDRINUSE error.

Find Process on macOS / Linux:

lsof -i :3000

Terminate Process on macOS / Linux:

First attempt a graceful termination (SIGTERM), which gives the application time to save state and cleanly close socket connections:

kill <PID>

If the process is frozen and unresponsive, send a forceful termination (SIGKILL):

kill -9 <PID>

Find and Kill Process on Windows (PowerShell):

Get-NetTCPConnection -LocalPort 3000 | Select-Object OwningProcess
Stop-Process -Id <PID> -Force

On this page