Port

A port is a numbered endpoint on your computer that allows different applications to communicate over the network simultaneously. When you visit localhost:3000, the '3000' is the port — it tells your browser which application to connect to. Different services run on different ports to avoid conflicts.

Example

Your Next.js app runs on port 3000, your PostgreSQL database on port 5432, and a separate API server on port 8080. Each service has its own door into your computer, so they don't interfere with each other.

Ports are like apartment numbers in a building. The building (your computer) has one address, but each apartment (port) houses a different service.

Common Ports

PortTypical Use
3000Next.js, React dev server
3001Secondary dev server
5173Vite dev server
5432PostgreSQL database
6379Redis
8080Alternative HTTP server
443HTTPS (production)
80HTTP (production)

The "Port Already in Use" Error

The most common port-related issue for vibe coders:

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

This means another process is already using that port. Fixes:

  1. Close the other app — Check if you have another dev server running
  2. Use a different portnpm run dev -- --port 3001
  3. Kill the process — Find and stop whatever's using the port

Ports in Development vs Production

In development, you explicitly see ports (localhost:3000). In production, ports are hidden:

  • yourapp.com → secretly uses port 443 (HTTPS)
  • Your hosting provider handles port routing automatically
  • Users never see or type port numbers

Why Different Ports?

When building full-stack applications, you might run multiple services simultaneously. Each needs its own port so your computer knows which service should handle each request.

Ad
Favicon