Agentic Research

Port

Also: 連接埠 · 端口 · port number · address already in use

A number appended to an address so one machine can run many network services at once without mixing them up.

When you will meet it

Local AI tools are really network services: Ollama, LM Studio and dev dashboards all "listen on a port on localhost". In localhost:3000, the 3000 after the colon is the port. When two programs claim the same one you get "Address already in use" — without this concept you cannot tell what to look for, or that changing the number is an option.

An analogy

The IP address is the building's street address; the port is the room number. Mail marked "this building, room 3000" reaches the right tenant. A service listening on port 8000 is a shop that hung its sign on room 8000 and answers when someone knocks.

Minimal example

python3 -m http.server 8000     # 在 8000 埠開一個測試用網頁伺服器(Ctrl+C 結束)

# 再開第二個終端機視窗、執行同一個指令,就會看到:
#   OSError: [Errno 48] Address already in use   ← 埠被占了

# 查出誰占著 8000(拿到 PID 就能 kill 掉):
lsof -i :8000                   # macOS 內建;Linux 裝 lsof 或用 ss -ltnp
netstat -ano | findstr :8000    # Windows

Ports run from 0 to 65535; those below 1024 are reserved for the system and need admin rights. Dev tools therefore crowd into the same big numbers — 3000, 8000, 8080, 11434 (Ollama's default) — which is exactly why they collide: everyone's default is one of those.

What people get wrong

  • Rebooting at "Address already in use". Finding the occupant is faster: usually it is your own previous run that never exited. lsof prints the PID; kill ends it (see the process entry).
  • Treating the port number as the service's identity. :3000 and :8080 may be two instances of one tool or two unrelated programs. A port is a room number, not an ID card — the COMMAND column of lsof tells you who is behind the door.

Related terms

Next