Guides

Port already in use — why it happens and how to fix it fast

Illustration: a door marked 3000 is already occupied from inside while a second figure waits outside

You run your project — and instead of the site, red text: Error: listen EADDRINUSE: address already in use :::3000, or just "port already in use." Translation: door 3000 is already taken by someone, and a second tenant can't squeeze in. And almost always the culprit isn't a bug in your code — it's a forgotten process. Let's go through three causes, most common first.

If the word "port" itself sounds fuzzy — start with what is a port, and the rest will make more sense.

Cause 1. An old process didn't close (99% of cases)

You already ran the project, closed the terminal tab or hit the wrong thing — and the server stayed alive in the background, still holding the port. The new run knocks on the same door and gets "taken."

How to check: ask the system who's sitting on the port.

  • macOS/Linux: lsof -i :3000 — shows the process and its number (PID).
  • Windows: netstat -ano | findstr :3000 — PID in the last column.

How to fix: evict that process by its PID.

  • macOS/Linux: kill -9 12345 (put your PID in place of 12345).
  • Windows: taskkill /PID 12345 /F.

Port free — run again. This fixes the overwhelming majority of cases.

Cause 2. The port is genuinely taken by another app

Sometimes a completely different program is on "your" port — another project, a Docker container, some background service. It's especially easy to collide on popular numbers like 8080.

How to check: the same lsof -i :3000 or netstat, but in the process name you'll see not your project, but something else.

How to fix — two paths:

  • Close that program, if you don't need it right now.
  • Or change your project's port — often it's one line in the settings or an environment variable (PORT=3001). Run on the next door over — no conflict. This is the most painless option when you don't know who the neighbor is.

Cause 3. Double launch or a stuck terminal

Sometimes it's as plain as it gets: you started the project twice — in a second terminal tab, or by hitting "Run" in the editor a second time. The first instance took the port, the second complains.

How to check: glance at your open terminal tabs and editor processes — is there already a running server?

How to fix: close the extra launch — in its tab, press Ctrl+C. If the tab got lost, go back to the method from cause 1 and kill the process by PID.

How do I find which process is holding the port?

With a command that asks the system "who's on this port." macOS/Linux: lsof -i :3000. Windows: netstat -ano | findstr :3000. The answer gives you the process name and its PID (a numeric id). You need the PID to close that exact process without touching the others.

Is it safe to just change the port?

Yes, completely. A port is only a door number — the app doesn't care which one it hangs on. Changing 3000 to 3001 breaks nothing — only the address you open changes: localhost:3001. It's a legitimate and often the fastest way out when you don't feel like fussing with someone else's process. If the site still won't open after that, the cause is different — see why localhost won't respond.

Learn vibe coding — don’t just read about it

Short story-lessons, an agent simulator and daily practice — in our mobile app. Free.

Open the app
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →