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.

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

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