Skip to main content
skill CX Codex

detecting-port-conflicts — Claude Code skill: setup and usage

Detects EADDRINUSE and port conflicts in terminal output, identifies blocking processes with lsof, and kills them or picks an open port for your dev server.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add spencerpauly/awesome-cursor-skills --skill detecting-port-conflicts -a claude-code
Open on GitHub

What detecting-port-conflicts does

The skill scans terminal logs for errors like EADDRINUSE, address already in use, or OSError: [Errno 98]. It grabs the blocked port number right away. Conflicting dev servers happen constantly. To diagnose the blocker, it runs lsof -i :<PORT> -P -n and identifies the PID and process name behind it.

Once diagnosed, the skill provides clean recovery paths. It can terminate the offending process with kill <PID> or kill -9 <PID>. Alternatively, it checks if the next port is free and adapts start commands for Vite or Next.js. When lsof returns empty, the port is likely stuck in TIME_WAIT state — waiting 30 seconds usually clears it.

The nuclear killall node command wipes out all running instances, so the skill only runs it after explicit user confirmation. Keep in mind that macOS requires root permissions for ports below 1024.

What it helps with

  • resolve dev server startup failures caused by EADDRINUSE
  • identify the blocking PID using lsof
  • switch dev servers to an open port in Vite or Next.js
  • detect zombie port binds left behind by stopped Docker containers

Example prompts for the agent

  • The server failed with EADDRINUSE, find what is using the port
  • Kill the process blocking the port and restart Vite
  • Check why the port is busy, find the PID or run the server on the next free port

How to install detecting-port-conflicts

1Skills CLI (Vercel)

npx skills add spencerpauly/awesome-cursor-skills --skill detecting-port-conflicts -a claude-code

2Manually: put the files in place

~/.claude/skills/detecting-port-conflicts/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/detecting-port-conflicts/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about detecting-port-conflicts

How to install detecting-port-conflicts in Claude Code?

Run npx skills add spencerpauly/awesome-cursor-skills --skill detecting-port-conflicts -a claude-code in your terminal.

What does detecting-port-conflicts do?

It intercepts port conflict errors in the terminal, pinpoints the blocking process ID, and either kills it or shifts your dev server to an open port.

What happens if lsof shows no process using the port?

The port might be in TIME_WAIT state. Wait 30 seconds for the system socket to close or bind your server to the next port.

Source text

SKILL.md · CC0-1.0
---
name: detecting-port-conflicts
description: Detect EADDRINUSE and port conflicts, find what's using the port, and resolve it by killing the process or suggesting an alternative port.
user-invocable: true
---

# Detecting Port Conflicts

When a dev server fails to start because a port is already in use, diagnose and resolve it.

## Detection

Scan terminal output for these patterns:
- `EADDRINUSE`
- `address already in use`
- `Port XXXX is already in use`
- `bind: address already in use`
- `OSError: [Errno 98] Address already in use`

Extract the port number from the error message.

## Diagnosis

Find what's using the port:

```bash
lsof -i :<PORT> -P -n
```

This shows the PID, process name, and user. Common culprits:
- A previous dev server that didn't shut down cleanly
- Another project's dev server
- A Docker container
- A system service

## Resolution Options

### Option 1: Kill the blocking process

```bash
kill <PID>
# If it doesn't stop:
kill -9 <PID>
```

Then restart the original server.

### Option 2: Use a different port

Suggest the next available port:

```bash
# Check if port+1 is free
lsof -i :<PORT+1> -P -n
```

Update the dev server config or start command:
- Next.js: `next dev -p <PORT>`
- Vite: `vite --port <PORT>`
- Express: set `PORT` env var
- Django: `python manage.py runserver <PORT>`

### Option 3: Kill all node processes (nuclear option)

```bash
killall node
```

Only suggest this if the user confirms — it kills everything.

## Tips

- On macOS, ports below 1024 require root
- Docker containers bind ports that persist even if the container is stopped — check `docker ps`
- If `lsof` shows nothing, the port may be in TIME_WAIT state — just wait 30 seconds or use a different port

© spencerpauly · CC0-1.0 · spencerpauly/awesome-cursor-skills

Similar skills

Everything for Backend and APIs →

From the same set59

babysitting-pr Monitors an open pull request for CI failures, review comments, and merge conflicts, then fixes issues locally and pushes updates. CX Codex +1 427installs finding-dev-server-url Scans running terminal sessions for dev server URLs and localhost ports. Useful when you need to locate active local endpoints or check port collisions. CX Codex +1 425installs best-of-n-solving Runs two or three approaches to a hard problem at once, each in its own git worktree, then helps you pick the winner. CX Codex +1 425installs converting-css-to-tailwind This skill walks a plain CSS file and rewrites its rules as Tailwind utility classes in your markup. Handy when a project moves off hand-written CSS. CX Codex +1 423installs setting-up-ci A skill that writes a GitHub Actions pipeline with linting, tests, type-checking and a deploy step. Useful when the repo has no CI yet. CX Codex +1 415installs adding-api-docs This skill writes OpenAPI/Swagger documentation for an API: endpoint schemas, request and response types, and an interactive docs page. CX Codex +1 413installs parallel-test-fixing The skill runs your test suite and assigns each failing test file to a separate subagent for parallel fixes. It helps when multiple test files break simultaneously across a codebase. CX Codex +1 412installs profiling-performance This skill profiles web application CPU performance using browser MCP tools. It captures call stacks and pinpoints slow functions causing interface lag. CX Codex +1 410installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor