---
title: "“Address already in use” on Mac: find the process on a port · Kilobat Guides"
url: "https://kilobat.app/guides/port-already-in-use"
description: "Find which process listens on a port with lsof, then stop it or choose another port, when a dev server says the address is already in use."
---

Developers

# Port already in use on a Mac

Only one process can listen on a TCP port and address. A second server then stops with “address already in use”.

Applies to: All current macOS versions. · Checked: 29 October 2026

## Symptoms

- A dev server stops with “EADDRINUSE” or “address already in use”.
- Docker cannot publish a port because “port is already allocated”.
- The port was free before a crash or a restart of your editor.

## Likely causes

- **An old copy of your server.** A server from an earlier run still runs in the background.
- **Another app.** A different app uses the same port. On macOS 12 and later, AirPlay Receiver uses ports 5000 and 7000.
- **A container.** A running container publishes the same port on the Mac.

## How to check

1. Find the process that listens on the port. Replace 3000 with your port.

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

   Output The COMMAND and PID columns name the process.
2. To see processes of other users, run the same command with sudo.

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

   Needs an administrator password.
3. Show more about the process.

   ```
   ps -p 12345 -o pid,command
   ```
4. Look for containers that publish the port.

   ```
   docker ps
   ```

## How to fix it

1. If the process is yours, stop it in its own Terminal window with Control-C.
2. Otherwise, send it the terminate signal. Use its PID.

   ```
   kill 12345
   ```
3. If it does not stop, use `kill -9`. The process cannot save its data.
4. If the process belongs to macOS, do not stop it. Choose another port for your server.
5. If the port is 5000 or 7000, read [Port 5000 or 7000 is in use on a Mac: AirPlay Receiver](https://kilobat.app/guides/airplay-receiver-port-5000).

## With Kilobat

1. List the open sockets of one process.

   ```
   kilobat destinations --pid 12345
   ```
2. Quit a process by PID. Add `--force` only if it does not stop.

   ```
   kilobat quit 12345
   ```

## Questions

**Why does lsof show nothing, but the port is in use?**

lsof shows only the processes that you can examine. Run it with sudo to see all processes.

**What do -n and -P do?**

They stop lsof from converting addresses to names and ports to service names. The output is faster and shows numbers.

## Sources

- lsof(8), man page installed with macOS 27.2
- kill(1) and ps(1), man page installed with macOS 27.2
- [Apple Support: TCP and UDP ports used by Apple software products](https://support.apple.com/en-us/103229)

Sources checked on 29 October 2026. Man pages are the ones installed with macOS; open one with `man <name>` in Terminal.

## Related guides

- [Port 5000 or 7000 is in use on a Mac: AirPlay Receiver](https://kilobat.app/guides/airplay-receiver-port-5000): Apple lists TCP ports 5000 and 7000 for AirPlay.
- [Cannot reach a Docker container from the Mac](https://kilobat.app/guides/docker-container-from-mac): Docker on a Mac runs containers in a Linux virtual machine.
- [A container cannot reach localhost on the Mac](https://kilobat.app/guides/localhost-from-container): Each container has its own network stack.
- [Find which app uses your bandwidth on a Mac](https://kilobat.app/guides/which-app-uses-bandwidth): Activity Monitor and nettop show which processes send and receive data.
