The short answer
On a Mac, port 5000 is usually held by AirPlay Receiver: lsof shows ControlCenter listening on ports 5000 and 7000. Turn off AirPlay Receiver in System Settings → General → AirDrop & Handoff, or run your app on another port. Port 3000 is usually a dev server still running; lsof -nP -iTCP:3000 -sTCP:LISTEN names it.
On this page
What the error looks like
Error: listen EADDRINUSE: address already in use :::5000
OSError: [Errno 48] Address already in useBoth mean the same thing: another process is already listening on that port, and only one can. Error 48 is macOS's number for it; Linux reports 98 for the same error.
Step 1: find what holds the port
lsof -nP -iTCP:5000 -sTCP:LISTENCOMMAND PID USER FD TYPE NODE NAME
ControlCe 753 you 11u IPv4 TCP *:5000 (LISTEN)
ControlCe 753 you 12u IPv6 TCP *:5000 (LISTEN)ps -o pid,command -p 753lsof cuts command names to 9 characters, so ControlCe is /System/Library/CoreServices/ControlCenter.app, the part of macOS behind Control Center and AirPlay Receiver. Use the same command with any port number. To see every listening port at once, run lsof -nP -iTCP -sTCP:LISTEN.
Port 5000 and 7000: AirPlay Receiver
Apple's list of ports used by its software gives TCP 5000 and TCP 7000 to AirPlay. With AirPlay Receiver on, your Mac listens on both so an iPhone or iPad nearby can stream to it. That collides with anything else that defaults to 5000: Flask's development server, for example, runs on 127.0.0.1:5000 unless you choose another port.
Option 1: turn off AirPlay Receiver
- Choose Apple menu → System Settings, then General.
- Click AirDrop & Handoff (called AirDrop & Continuity in Apple's newer guide).
- Turn off AirPlay Receiver.
- Run
lsof -nP -iTCP:5000 -sTCP:LISTENagain: it should print nothing.
The trade-off: you can't stream from an iPhone or iPad to this Mac until you turn it back on.
Option 2: run your app on another port
flask --app app run --port 5001npx next dev -p 3001This leaves AirPlay alone and avoids the clash for good. Update any URLs, proxies or callbacks that name the old port.
Port 3000: usually a dev server you left running
On our test Mac nothing from macOS listened on 3000. Next.js, Rails and many Node frameworks default to it, so when 3000 is taken it's almost always a dev server from another project, another terminal tab, or a coding agent session that ended without stopping it.
lsof -nP -iTCP:3000 -sTCP:LISTEN
ps -o pid,ppid,user,etime,command -p <PID>- Read the command line: it usually includes the project's folder.
- If it's a project you still use, stop it from its own terminal with Control-C, or run your new server on another port.
- If it's a leftover, check it's yours, then stop that one PID with
killand the PID number.
Don't stop processes by name: pkill node stops every Node process, your editor's included. The checks to make before stopping a leftover, owner, project folder and parent process, are in how to kill leftover dev servers.
| Port | Usually held by |
|---|---|
| 5000, 7000 | AirPlay Receiver (ControlCenter) |
| 3000 | A dev server: Next.js, Rails, Express and others |
| 5173 | A Vite dev server |
| 5432 | PostgreSQL |
| 8080, 8000 | Local web servers, proxies and Python's built-in server |
5000, 7000
- Usually held by
- AirPlay Receiver (ControlCenter)
3000
- Usually held by
- A dev server: Next.js, Rails, Express and others
5173
- Usually held by
- A Vite dev server
5432
- Usually held by
- PostgreSQL
8080, 8000
- Usually held by
- Local web servers, proxies and Python's built-in server
The faster way: dev servers by project in iKnowMyMac
iKnowMyMac's Projects screen lists every dev server by project, with its ports, runtime, uptime, memory and idle time, and tells you when two servers collide. AirPlay Receiver isn't a dev server, so it isn't in that list; for 5000, use the setting above.