Localhost · Ports, dev servers and previews on your Mac

Port 3000 Already in Use on Mac? Find the Project Behind It

Find which project is using port 3000 on your Mac, decide whether to keep it running, and get your app preview working again — without killing your browser.

Illustration: a robot already sits in the :3000 port while a second robot waits outside with a box
Using an AI agent?View as MarkdownOpen in ClaudeOpen in ChatGPT

You're working on two projects. Yesterday your coding assistant started the landing page. Today you ask it to start the dashboard, and instead of a preview you get this:

Error: listen EADDRINUSE: address already in use :::3000

Or there's no error at all. You open localhost:3000 and see the landing page instead of the dashboard.

In this guide:

  • A request you can paste into your coding assistant. It checks the port and touches nothing.
  • A simple choice: keep the server, stop it, or move to another port.
  • What to do if the server comes back after you stop it.
  • The exact Terminal commands, folded away for when you or your agent need them.

What does “port already in use” mean?

A port is like a door number on your Mac. A web server stands behind one door and waits for visitors. Only one server can wait behind the same door at the same address, so when a second one tries, Node.js refuses with EADDRINUSE, short for “address already in use”.

The error tells you the door is taken. It doesn't tell you by whom, and the server holding the door is often something you still need.

Which of your projects is already running?

The fastest way is to ask your coding assistant to look. It finds the program on the port, tells you which project folder it runs from, and changes nothing.

Give this to your agent · Check, don't touch

Find out what is listening on TCP port 3000 on this Mac. For each process, show its PID, the full command and the folder it runs from. Tell me which of my projects it most likely is and what you're not sure about. Hide anything that looks like a key, token or password. Only look: don't stop, restart or change anything. Wait for my decision.

The last two sentences matter. Without them, many assistants “helpfully” kill the process right away. Read what it found before you approve anything.

Here is what the check does, in plain words:

  1. Find who is behind the door. The program waiting on port 3000 and its process number, the PID.
  2. See what that program is. Often it only says next-server, which doesn't tell five Next.js projects apart.
  3. Look at the folder it runs from. That folder is your project, for example landing. Now you know who holds the port.
The same check in Terminalfor you or your agent

1. Find the listener.

lsof -nP -iTCP:3000 -sTCP:LISTEN
COMMAND   PID  USER  FD   TYPE  ...  NAME
node      990  you   13u  IPv6  ...  TCP *:3000 (LISTEN)

-sTCP:LISTEN keeps only the server and leaves out everything that merely talks to it, such as your browser tab.

2. See what the process is. Replace 990 with your PID. Keep the PPID (parent process ID) in mind: it shows who started the server.

ps -ww -p 990 -o pid,ppid,command

3. See which folder it runs from. The last column is the project folder.

lsof -a -p 990 -d cwd

Two things you might see in step 1:

  • Two lines for the same port. The same PID twice is one server on IPv4 and IPv6, which is normal. Two different PIDs are two servers: macOS lets one listen on 127.0.0.1:3000 and another on *:3000 at the same time, with no error. Check both.
  • Docker, OrbStack or ssh in the COMMAND column (lsof cuts names to 9 characters, so Docker may show as com.docke). A container or an SSH tunnel holds the port. Stop that container (find it with docker ps), not Docker itself, or close the tunnel in the terminal that opened it.

Do you still need that project?

What you foundWhat to do
The project you're trying to start is already runningJust open it. No need to start it twice.
A different project you still needKeep it. Start the new one on another port, like 3001.
A project you're done withStop it the normal way (next section).
Something you don't recognizeLeave it until you know what it is.
Give this to your agent · Keep it, use another port

Leave the server on port 3000 running. Check that port 3001 is free, then start this project on 3001 with its usual start script. If 3001 is taken, use the next free port. Don't stop anything. Show me the exact address from the startup output.

Start on another port yourselffor you or your agent

For Next.js, run this from the new project's folder. The extra -- passes the flag through npm to Next.js. Vite takes --port too; other tools differ, so check the project's start script.

npm run dev -- --port 3001

How do you stop it without breaking anything?

Stop it where it was started. If its Terminal window is still open, click it and press Control-C. If a Run task in your editor (VS Code or Cursor), a process manager like pm2 (a tool that restarts servers) or your assistant started it, stop it there.

If that window is gone, stop that one process and nothing else. Your assistant can do it for you, carefully:

Give this to your agent · Stop only that one

Stop only the server that runs from the [folder you found] folder and listens on port 3000. Right before stopping it, check that it's still the same process. Use a normal stop, not a force kill. Then confirm that port 3000 is free and tell me if anything starts it again.

Prefer a window to commands? Open Activity Monitor, choose View → All Processes, select the process with your PID, click the ✕ button in the toolbar, then choose Quit, not Force Quit.

Stop it in Terminalfor you or your agent

Check the PID again first, because numbers get reused. Then ask the server to shut down (replace 990 with your PID) and run the step 1 check again to confirm the port is free:

kill -TERM 990
lsof -nP -iTCP:3000 -sTCP:LISTEN

Use kill -KILL only for a process you've identified that won't stop, since it skips any cleanup. The popular lsof -ti :3000 | xargs kill lists clients too; the safe form is lsof -ti tcp:3000 -sTCP:LISTEN, and even then, look before you kill. npx kill-port 3000 targets only the listener but force-kills by default.

Coming nextOpen a Localhost Project on Your Phone: Wi-Fi, USB or Tunnel?

Why does localhost:3000 show the wrong project?

Because the new server may not be on 3000 at all. Next.js (when you didn't set a port) and Vite (unless its strictPort option is on) don't fail: they move to the next free port and say so in one line of the startup log that's easy to miss. Next.js 16 even names the process holding 3000: “Port 3000 is in use by process 990, using available port 3001 instead”. Your dashboard is running happily on localhost:3001 while the browser still shows yesterday's landing page on 3000.

Read the address in the startup output instead of typing 3000 from habit. If the address is right and you still see the old page, reload without the cache (Shift-Command-R in Chrome or Firefox; in Safari, open the address in a private window).

Nothing shows up, but the error stays?

  • Check right after the error. A server that crashes and restarts can be gone for a second.
  • It may belong to another user on the Mac. The same check with admin rights shows it. Don't use admin rights to stop something you can't identify.
  • The port is 5000 or 7000. If the program is called ControlCe, that's macOS Control Center: the AirPlay Receiver listens there. Turn it off in System Settings → General → AirDrop & Handoff → AirPlay Receiver, or use another port.
The admin-rights checkfor you or your agent

Read-only, it only looks:

sudo lsof -nP -iTCP:3000 -sTCP:LISTEN

You stopped it, and it came back?

Then something keeps restarting it: a process manager like pm2 (a tool that restarts servers), a file watcher, a macOS launch agent (a background job that starts at login), a Run task in your editor, your coding assistant, or a “keep alive” option in a tool like AI Garage. Find what restarts it, turn the restart off there, then stop the server once. Killing it harder won't help.

Follow the parent chainfor you or your agent

Take the PPID from step 2 and look at the parent. Repeat with each new parent until you reach something you recognize. On our test Mac the chain went next-server → next dev → npm run dev, which pointed straight at the terminal tab that started it.

ps -ww -p <PPID> -o pid,ppid,command

If you run several projects every day

For a one-off conflict, the steps above are enough. If your coding assistant starts servers for you every day, it gets hard to remember which project sits on which port. After a long agent session, run through what to check when your AI agent left dev servers running.

Sources

Checked on November 16, 2026. Commands were run on macOS 15.7.4 with Node.js 24; port behaviour checked for Next.js 16.2 and Vite 7.3.

  • lsof manual: the -i, -sTCP:LISTEN, -a and -d cwd options (lsof-org/lsof).
  • Node.js: common system errors, EADDRINUSE (nodejs.org).
  • Next.js CLI: changing the port with -p and passing flags through npm run (nextjs.org).
  • npm: how -- passes arguments to a script (docs.npmjs.com).
  • Vite: server.port and server.strictPort (vite.dev).
  • Apple: quitting a process in Activity Monitor (support.apple.com).

Next up:AI Agent Left Dev Servers Running? Find Them on Your Mac

Explore more:LocalhostMCP, simplySecurity

More on your setup

swipe sideways
MCP, simplySoon
Where Each AI Client Stores Its MCP Config (and How to Add a Server)
Config paths for every client, with the date we checked.
SecuritySoon
Stop Pasting API Keys Into AI Chats: Safer Ways to Get a Secret Into .env
A setup where the key never passes through the chat.
LocalhostSoon
Open a Localhost Project on Your Phone: Wi-Fi, USB or Tunnel?
Same network, cable or tunnel: pick the right way in one minute.
Top picksSoon
ngrok Alternatives for Local Dev on Mac
Cloudflare Tunnel, Tailscale and others in one honest table.
MCP, simplySoon
Use One Skill in Claude Code and Codex
One skill folder that works for two agents.
LocalhostSoon
What Is Localhost, and Why localhost:3000 Shows the Wrong Project
Localhost in plain words, plus the wrong-project case.

Essentials

Five guides to read first
1
Localhost8 min read
AI Agent Left Dev Servers Running? Find Them on Your Mac
A checklist for after a Claude Code, Codex or Cursor session: find background Node processes and dev servers still running on your Mac, stop them one by one.
2
MCP, simplySoon
Where Each AI Client Stores Its MCP Config (and How to Add a Server)
Config paths for every client, with the date we checked.
3
SecuritySoon
Stop Pasting API Keys Into AI Chats: Safer Ways to Get a Secret Into .env
A setup where the key never passes through the chat.
4
LocalhostSoon
Open a Localhost Project on Your Phone: Wi-Fi, USB or Tunnel?
Same network, cable or tunnel: pick the right way in one minute.
5
Top picksSoon
ngrok Alternatives for Local Dev on Mac
Cloudflare Tunnel, Tailscale and others in one honest table.