CH. 02 Ports · the doors of a computer

Localhost ports, explained

In localhost:3000, localhost picks the computer and 3000 picks the program. A port is a numbered door — every computer has 65,535 of them — and your browser just knocked on one.

Ports per address
65,535
Programs per port
One
Most famous
:3000
Fig. 01 — 127.0.0.1, the building · ports, the doorsInteractive
A computer drawn as a building with numbered doors The computer at 127.0.0.1 is a building. Each door is a port: 22, 80, 443, 3000, 3001, 5173, 5432, 6000, 8080 and any other number. Doors with a green light have a program listening behind them. The browser sends a request to one door at a time. localhost:3000 YOUR BROWSERON THIS COMPUTER 127.0.0.1 · LOCALHOST 65,535 DOORS PER ADDRESS · PORT 0 IS RESERVED 22SSH 80HTTP 443HTTPS 3000YOUR APP 3001EMPTY 5173VITE 5432POSTGRES 6000X11 8080ALT HTTP …ANY PORT

Pick a port and send a request

Green lights mean a program is listening behind that door. Try turning your app off, then knock on :3000.

§ 01 The short answer

What is a port?

Quick answer

A port is a number from 0 to 65535 that identifies one program on a computer. The IP address gets data to the right machine; the port gets it to the right program on that machine.

localhost:3000 means “the program listening on port 3000 on this computer.” If nothing is listening there, the connection is refused.

Rules How ports behave

  • One program per port. When a server starts, it listens on a port and claims it. A second program asking for the same port fails with EADDRINUSE — “address already in use.”
  • Both ends have one. Your browser also uses a port — a random, temporary one like 52814 — for each connection it opens.
  • The defaults are invisible. http:// means port 80 and https:// means 443, which is why real websites never show a port.
  • TCP and UDP are separate. Each protocol has its own 65,536 ports (0–65535). Web traffic uses TCP — except HTTP/3, which runs over UDP.

§ 02 The map

The three port ranges

The IANA registry splits the 65,536 ports into three ranges (RFC 6335). Drawn to scale, the famous ports barely show up.

Fig. 02 — Ports 0–65535, drawn to scaleTCP · same for UDP
0–1023 · System (“well-known”)Classic services: 22 SSH, 53 DNS, 80 HTTP, 443 HTTPS. On many systems, listening here needs admin rights. 1.6% of the space.
1024–49151 · Registered (“user”)Where apps and dev servers live: 3000, 5173, 5432, 8080. Anyone can listen here. 73.4% of the space.
49152–65535 · Dynamic (“ephemeral”)Handed out by your OS for the client side of outgoing connections. (Linux uses 32768–60999 by default.) 25% of the space.

§ 03 Reference

Common localhost ports and what runs on them

The defaults you'll meet most often while developing. A port is only a convention — any program can listen on any free port — but these are where things usually live.

PortWhat usually runs thereNotes
Web servers & app frameworks
80HTTP — the default for http://Browsers hide it: http://localhost means port 80.
443HTTPS — the default for https://Local HTTPS needs a certificate (tools like mkcert help).
1234Parcel · LM Studio local API
1313Hugo (hugo server)
3000Next.js, Nuxt, Ruby on Rails, Docusaurus, Grafana, Express & Bun examplesThe most famous dev port of all.
3001The next try when 3000 is takenNext.js and others move up one port automatically.
4000Phoenix (Elixir), Jekyll, Firebase Emulator UI
4173Vite preview (vite preview)Serves your production build locally.
4200Angular CLI (ng serve)
4321AstroDefault since Astro 3.0. Read it as a countdown.
5000Flask · older ASP.NET Core templatesOn macOS 12+, AirPlay Receiver already listens here.
5173Vite dev server — React, Vue, Svelte, SvelteKit5173 spells VITE: V=5, I=1, T=7, E=3.
5500VS Code Live Server extension
6006Storybook · TensorBoard
7860Gradio · Stable Diffusion web UI
8000Django, python -m http.server, FastAPI/Uvicorn, Laravel, Gatsby, Deno“80, but unprivileged.”
8080Spring Boot, Tomcat, Jenkins, webpack-dev-server, Vue CLI, many Docker imagesThe classic alternative HTTP port.
8081React Native Metro bundler
8188ComfyUI
8443Alternative HTTPS
8501Streamlit
8787Cloudflare Workers (wrangler dev)
8888Jupyter Notebook · Netlify Dev
9000PHP-FPM, MinIO, SonarQubeA crowded one — conflicts are common.
9229Node.js debugger (node --inspect)
11434Ollama (local LLMs)
Databases, queues & data
1433Microsoft SQL Server
2181Apache ZooKeeper
3306MySQL · MariaDB
5432PostgreSQLNot a web server — opening it in a browser fails.
5555Prisma Studio
5601Kibana
5672 · 15672RabbitMQ · its management UI
5984CouchDB
6379Redis · Valkey
7474 · 7687Neo4j (HTTP · Bolt)
8086InfluxDB
8123ClickHouse HTTP · Home Assistant
9042Apache Cassandra
9092Apache Kafka
9200Elasticsearch · OpenSearch
11211Memcached
27017MongoDB
54321–54324Supabase local stack (API, Postgres, Studio, email)From supabase start.
Infrastructure & tools
22SSHBrowsers refuse to open it.
25 · 587SMTP (sending email)
53DNS
1025 · 8025Mailpit · MailHog (SMTP · web inbox)Catch outgoing email while developing.
2375 · 2376Docker Engine API (plain · TLS)Never expose 2375 to a network.
3100Grafana Loki
4566LocalStack (AWS services, locally)
5678n8n
6443Kubernetes API server
8200HashiCorp Vault
8500HashiCorp Consul
8545Ethereum JSON-RPC (Hardhat, Anvil)
9090Prometheus
16686Jaeger UI
25565Minecraft server
32400Plex Media Server

§ 04 Field notes

Why 3000? Why 8080?

Port numbers look random. Most of them have a story.

:8080 · :8000 · :8888

“80, but unprivileged”

HTTP's real port is 80, and on Unix-like systems ports below 1024 traditionally required root. So developers picked lookalikes anyone can open: 8080, 8000, 8888.

:3000

The Rails era

Ruby on Rails shipped with port 3000 in 2004. A generation of Node.js tutorials, Create React App and Next.js followed — and 3000 became the default “my app” port.

:5173

A port that spells its name

Vite's default reads V-I-T-E: 5 is V in Roman numerals, 1 looks like I, 7 like T, and 3 like a backwards E.

:5000 on a Mac

AirPlay got there first

Since macOS Monterey, AirPlay Receiver listens on 5000 (and 7000) — so Flask can fail with “address already in use.” Turn it off in System Settings → General → AirDrop & Handoff, or use --port 5001.

:52814

Your browser's side

Every connection has two ports. Yours is temporary — your OS picks it from the dynamic range and frees it when the connection closes.

:0

The port that means “any”

Port 0 is reserved. Ask your OS to listen on port 0 and it picks a free port for you — a trick test suites use to avoid collisions.

§ 05 Commands

Which program is using a port?

When a server won't start because its port is taken, find out who's behind that door, then stop it — or start your app on another port.

Replace 3000 with your port. For a fuller walkthrough of the errors you might see, read “port already in use” in the troubleshooting guide.

macOS

Terminal
# Who is listening on port 3000?
lsof -nP -iTCP:3000 -sTCP:LISTEN

# Stop it (use the PID from the output)
kill <PID>

# Every listening port on this Mac
lsof -nP -iTCP -sTCP:LISTEN

Linux

Terminal
# Who is listening on port 3000?
sudo ss -ltnp 'sport = :3000'

# Stop it (use the PID from the output)
kill <PID>

# Or in one step
sudo fuser -k 3000/tcp

Windows

PowerShell
# Who is listening on port 3000?
Get-NetTCPConnection -LocalPort 3000 -State Listen

# Stop it (OwningProcess from the output)
Stop-Process -Id <PID>

# Classic Command Prompt version
netstat -ano | findstr :3000
taskkill /PID <PID> /F

§ 06 Browser rules

Ports your browser refuses to open

Open http://localhost:6000 and Chrome shows ERR_UNSAFE_PORT; Firefox says “This address is restricted.” Nothing is wrong with your server: browsers block web requests to a short list of ports that belong to other protocols, so a malicious page can't trick your browser into talking to, say, a mail server.

The list lives in the Fetch standard. If your app picked one of these by accident, move it to another port.

Blocked portBelongs to
21 · 22 · 23FTP · SSH · Telnet
25 · 110 · 143 · 587 · 993Email (SMTP, POP3, IMAP)
53DNS
2049 · 4045NFS file sharing
5060 · 5061SIP (internet telephony)
6000X11 (graphical desktops)
6665–6669 · 6697IRC chat
10080Amanda backups

A selection — the standard lists about 80 ports, most of them below 1024.

§ 07 FAQ

Port questions, answered

What is localhost:8080?

Whatever program on your own computer is listening on port 8080. It's the classic “alternative HTTP” port, used by Spring Boot, Tomcat, Jenkins, webpack-dev-server, Vue CLI and many Docker images. If nothing is listening there, your browser shows “localhost refused to connect.”

What is localhost:3000?

The program listening on port 3000 on your computer — most often a Next.js, Nuxt, Ruby on Rails or Node.js development server. It only works while that server is running, and only on your machine.

What is localhost:5173?

Vite's development server. React, Vue, Svelte and SvelteKit projects created with Vite open there by default. The number spells VITE: 5 is V in Roman numerals, then 1, 7 and 3 stand in for I, T and E.

What is localhost:8000?

Usually Django's runserver, Python's built-in http.server, FastAPI with Uvicorn, or Laravel's artisan serve. Like 8080, it's a lookalike of HTTP's port 80 that doesn't need admin rights.

Can two programs use the same port?

Not on the same address at the same time. The first program to listen claims the port; the second fails with an error like EADDRINUSE (“address already in use”). Stop the first one, or start the second on a different port.

How many ports are there?

65,536 per protocol: TCP and UDP each have ports 0 through 65535, and port 0 is reserved. Ports 0–1023 are system ports, 1024–49151 are registered ports, and 49152–65535 are dynamic ports your operating system hands out for outgoing connections.

Why is port 5000 already in use on my Mac?

Since macOS Monterey, AirPlay Receiver listens on port 5000 (and 7000). Turn it off in System Settings → General → AirDrop & Handoff, or run your app on another port, for example flask run --port 5001.

Is localhost:3000 the same as 127.0.0.1:3000?

They reach the same server, but your browser treats them as different sites: cookies, logins and localStorage saved on one won't appear on the other. And if localhost resolves to IPv6 (::1) while your server only listens on 127.0.0.1, only one of them will work.