detecting-port-conflicts
Detect EADDRINUSE and port conflicts, find what's using the port, and resolve it by killing the process or suggesting an alternative port.
Install
npx skills add https://github.com/spencerpauly/awesome-cursor-skills/tree/main/resources/detecting-port-conflicts
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install spencerpauly-awesome-cursor-skills@llmmart
git clone https://github.com/spencerpauly/awesome-cursor-skills.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole spencerpauly/awesome-cursor-skills collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
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:
EADDRINUSEaddress already in usePort XXXX is already in usebind: address already in useOSError: [Errno 98] Address already in use
Extract the port number from the error message.
Diagnosis
Find what's using the port:
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
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:
# 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
PORTenv var - Django:
python manage.py runserver <PORT>
Option 3: Kill all node processes (nuclear option)
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
lsofshows nothing, the port may be in TIME_WAIT state — just wait 30 seconds or use a different port
Files (awesome-cursor-skills)
-
SKILL.md 1.7 KB
--- 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
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.