You start a server and get “address already in use” (EADDRINUSE), or a port you need is taken and you don't know by what.
- `Error: listen EADDRINUSE: address already in use :::3000` from Node.
- `OSError: [Errno 48] Address already in use` from Python.
- A dev server picks another port on its own, or won't start.
- Port 5000 or 7000 is busy even though you never started anything there.
Quick fix
Find the process listening on the port (replace 3000):
lsof -nP -iTCP:3000 -sTCP:LISTEN
The second column is the PID. Stop it gracefully, then forcefully only if needed:
kill 12345 # asks the process to quit
kill -9 12345 # forces it, if it ignores the first
Add sudo to lsof if the process belongs to another user or root.
Why it happens
| An old instance of your dev server is still running (another Terminal tab, a crashed watcher, a background job). | Most likely |
| AirPlay Receiver (ControlCenter) listens on ports 5000 and 7000. | Most likely |
| A Docker container publishes the same port. | Sometimes |
| A system or Homebrew service (Postgres 5432, Redis 6379, MySQL 3306) is running. | Sometimes |
| The socket is in TIME_WAIT right after the previous process exited. | Rarely |
Fixes
Find and stop the process
- Run
lsof -nP -iTCP:PORT -sTCP:LISTENand note the COMMAND and PID. - If it's your own server, quit it in its Terminal tab with Ctrl+C, or
kill PID. - Use
kill -9 PIDonly if it doesn't stop; it gives the process no chance to clean up. - One-liner:
lsof -tiTCP:3000 -sTCP:LISTEN | xargs kill(prints nothing if no process).
- Run
Free ports 5000 and 7000 (AirPlay Receiver)
- Open System Settings › General › AirDrop & Handoff.
- Turn off AirPlay Receiver. ControlCenter releases both ports immediately.
- Or leave it on and run your app on another port, such as 5001.
Docker and services
docker ps --format '{{.Names}} {{.Ports}}'shows which container publishes the port; stop it withdocker stop NAME.brew services listshows Homebrew services;brew services stop postgresql@16stops one.
UDP ports
- For UDP, drop
-sTCP:LISTEN:lsof -nP -iUDP:5353.
- For UDP, drop
Still not working?
If lsof shows nothing but binding still fails, the port may be held briefly in TIME_WAIT (wait a minute, or set SO_REUSEADDR in your server), or the process runs as another user (sudo lsof …). Ports below 1024 can be bound by normal users on modern macOS, so permissions are rarely the issue.
See it in the app
LightAtom's Ports view lists every open port with the app, PID and user behind it, so you can see what holds a port without remembering lsof flags. Right-click to copy the PID or reveal the program in Finder.
Frequently asked questions
How do I see what is using a port on my Mac?
Run lsof -nP -iTCP:PORT -sTCP:LISTEN in Terminal. It shows the command, PID and user of the process listening on that port.
Why is port 5000 already in use on my Mac?
Since macOS Monterey, ControlCenter listens on ports 5000 and 7000 for AirPlay Receiver. Turn it off in System Settings › General › AirDrop & Handoff, or use another port.
Is it safe to kill -9 a process?
It's safe for your own dev servers, but the process can't save state or clean up. Try a plain kill first and avoid killing system processes.
What does EADDRINUSE mean?
Address in use: another socket is already bound to that address and port, so your program can't listen there.
How do I kill whatever is on port 3000 in one command?
lsof -tiTCP:3000 -sTCP:LISTEN | xargs kill. The -t flag prints only PIDs, which xargs passes to kill.