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

Source: https://ai-garage.dev/blog/port-already-in-use-mac · Updated 2026-11-16 · Facts checked 2026-11-16 · By Az, maker of AI Garage

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:

```text
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 short:** Another server is already using port 3000. Usually it's one of your own projects that is still running. Don't kill everything on the port. Find out which project it is first, then keep it and start the new one on another port, or stop it the normal way.

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

**Prompt for your agent — Check, don't touch:**

```text
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 Terminal

**1. Find the listener.**

```sh
lsof -nP -iTCP:3000 -sTCP:LISTEN
```

```text
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.

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

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

```sh
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 found | What to do |
| --- | --- |
| The project you're trying to start is already running | Just open it. No need to start it twice. |
| A different project you still need | Keep it. Start the new one on another port, like 3001. |
| A project you're done with | Stop it the normal way (next section). |
| Something you don't recognize | Leave it until you know what it is. |

**Prompt for your agent — Keep it, use another port:**

```text
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 yourself

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.

```sh
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:

**Prompt for your agent — Stop only that one:**

```text
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.

> **Careful: Why the popular one-liner can close your browser.** Many answers suggest a one-line command that kills “whatever is on port 3000”. It also catches every program connected to that port, and on your Mac that is usually the browser tab showing localhost:3000. We checked: with one extra connection open, it returned two processes, the server and the client. Stop one process you've identified, and avoid `killall node`, which stops every Node.js project at once.

### Stop it in Terminal

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:

```sh
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.

## 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 check

Read-only, it only looks:

```sh
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 chain

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.

```sh
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](https://ai-garage.dev/blog/find-dev-servers-left-running-mac).

**See what's listening on each port, in one window.** AI Garage is a free macOS panel we build. It lists the ports listening on your Mac, shows the project folder when it can tell, and gives each saved project Start, Stop and Restart buttons. One command to launch; after that, buttons. Honest limits: it shows that a port is open, not that your app works. In the current version, Free port can also stop a browser or editor connected to that port, so use Stop on the project card. A fix is in development. Run `npx ai-garage` to try it.

## 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](https://github.com/lsof-org/lsof/blob/master/Lsof.8)).
- Node.js: common system errors, `EADDRINUSE` ([nodejs.org](https://nodejs.org/api/errors.html#common-system-errors)).
- Next.js CLI: changing the port with `-p` and passing flags through `npm run` ([nextjs.org](https://nextjs.org/docs/app/api-reference/cli/next)).
- npm: how `--` passes arguments to a script ([docs.npmjs.com](https://docs.npmjs.com/cli/v10/commands/npm-run-script)).
- Vite: `server.port` and `server.strictPort` ([vite.dev](https://vite.dev/config/server-options)).
- Apple: quitting a process in Activity Monitor ([support.apple.com](https://support.apple.com/guide/activity-monitor/quit-a-process-actmntr1002/mac)).
