Skip to content

Guide

Port 5000 or 3000 already in use on a Mac: what's using it

Your server won't start because the port is taken, and you didn't start anything on it. On a Mac, port 5000 has a usual suspect, and port 3000 has another. Here's how to tell which, and what to do.

By · Updated · 5 min read

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

Trying to listen on port 5000 on our test Mac, in Node.js and Python
Error: listen EADDRINUSE: address already in use :::5000
OSError: [Errno 48] Address already in use

Both 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

Who is listening on port 5000
lsof -nP -iTCP:5000 -sTCP:LISTEN
Output on our test Mac (shortened)
COMMAND   PID USER  FD  TYPE NODE NAME
ControlCe 753 you   11u IPv4 TCP  *:5000 (LISTEN)
ControlCe 753 you   12u IPv6 TCP  *:5000 (LISTEN)
The full name of that process
ps -o pid,command -p 753

lsof 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

  1. Choose Apple menu → System Settings, then General.
  2. Click AirDrop & Handoff (called AirDrop & Continuity in Apple's newer guide).
  3. Turn off AirPlay Receiver.
  4. Run lsof -nP -iTCP:5000 -sTCP:LISTEN again: 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 on port 5001
flask --app app run --port 5001
Next.js on port 3001
npx next dev -p 3001

This 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.

Who holds port 3000, and what it's running
lsof -nP -iTCP:3000 -sTCP:LISTEN
ps -o pid,ppid,user,etime,command -p <PID>
  1. Read the command line: it usually includes the project's folder.
  2. 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.
  3. If it's a leftover, check it's yours, then stop that one PID with kill and 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.

  • 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
Ports you'll often find taken on a Mac

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.

FAQ

Questions

Something else? support@iknowmymac.com

What is using port 5000 on my Mac?

Usually AirPlay Receiver. Run lsof -nP -iTCP:5000 -sTCP:LISTEN: if the command is ControlCe (ControlCenter), it's AirPlay. Apple lists TCP 5000 and 7000 as AirPlay ports.

How do I free port 5000 on a Mac?

Turn off AirPlay Receiver in System Settings → General → AirDrop & Handoff, or start your app on another port, such as flask --app app run --port 5001.

Why is port 3000 already in use?

A dev server is still running, often from another project or a terminal you closed. lsof -nP -iTCP:3000 -sTCP:LISTEN shows its PID, and ps -o command -p and the PID shows which project.

What does “address already in use” mean?

Another process is already listening on the port your server asked for. Only one process can listen on a given port and address. Find it with lsof, then stop it or pick another port.

Should I turn off AirPlay Receiver?

Only if you need port 5000 or 7000 and don't stream to this Mac from an iPhone or iPad. Otherwise, moving your app to another port avoids the clash without changing anything in macOS.

Know why your Mac is slow.

macOS 15 Sequoia or later · Apple silicon. A 51.4 MB native app, notarized by Apple. No account, no analytics, no telemetry.

One-time purchase · every feature · 14-day refund