MCPcopy Index your code
hub / github.com/doganarif/portfinder

github.com/doganarif/portfinder @v0.2.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.1 ↗ · + Follow
79 symbols 176 edges 8 files 35 documented · 44% 60 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

pf

A modern CLI tool to identify and manage processes using network ports.
Built with Go for speed, clarity, and zero runtime dependencies.

Go Version License Platform

🎬 Preview

pf in action


✨ Features

  • 🔍 Smart Process Detection — Instantly find what's using your ports
  • 📁 Project Awareness — Shows which project/directory owns the process
  • 🐳 Docker Support — Identifies containerized processes
  • 🎯 Quick Actions — Kill processes interactively or directly
  • 📊 Port Overview — Check all common development ports
  • 🚀 Fast & Lightweight — Single binary, no runtime dependencies

📦 Installation

✅ Using Homebrew (macOS/Linux)

brew tap doganarif/tap
brew install pf

🪟 Windows

Download the latest .exe file from the Releases Page:

  • For 64-bit Windows: pf-windows-amd64.exe
  • For ARM64 Windows: pf-windows-arm64.exe

Rename it to pf.exe and add to your PATH.

🧰 Using Go

go install github.com/doganarif/portfinder/cmd/portfinder@latest

This installs the binary as pf.

📁 Download Binary

Grab the latest release from the Releases Page.


🧪 Usage

🔍 Check a specific port

pf 3000

Output:

🔍 Port 3000 is in use by:

Process     node
PID         48291
Command     npm run dev
Project     ~/projects/my-react-app
Started     3 hours ago

Kill this process? [y/n]

📊 Check common development ports

pf check

Example output:

📊 Common Development Ports:

Frontend:
  ❌ 3000: node (my-react-app)
  ✅ 3001: free
  ✅ 4200: free
  ❌ 5173: vite (my-vue-app)
  ✅ 8080: free

Backend:
  ✅ 4000: free
  ❌ 5000: python (flask-api)
  ✅ 8000: free
  ✅ 9000: free

Databases:
  ✅ 3306: free
  ❌ 5432: postgres (docker)
  ❌ 6379: redis
  ✅ 27017: free

📋 List all ports in use

pf list

💀 Kill a process

pf kill 3000

⚙️ Common Ports Reference

Port Common Use
3000 React, Node.js, Rails
3001 Create React App fallback
4200 Angular
5173 Vite
5000 Flask, Python servers
8000 Django
8080 General web development
3306 MySQL/MariaDB
5432 PostgreSQL
6379 Redis
27017 MongoDB
9200 Elasticsearch
9090 Prometheus
3100 Grafana Loki
8983 Solr

🛠️ Configuration

You can override the default list of common ports by creating a config file at:

~/.config/portfinder/config.json

Example:

{
  "common_ports": [3000, 3001, 5173, 5000, 8000]
}

🧑‍💻 Development

Prerequisites

  • Go 1.21+
  • Make (optional)

Building from source

# Clone the repository
git clone https://github.com/doganarif/portfinder.git
cd portfinder

# Build
make build

# Run tests
make test

# Install locally
make install

📁 Project Structure

pf/
├── cmd/
│   └── portfinder/     # CLI entry point
├── internal/
│   ├── config/         # Configuration management
│   ├── process/        # Process detection logic
│   └── ui/             # Terminal UI components
├── Makefile            # Build automation
└── README.md           # This file

🤝 Contributing

Contributions are welcome! Please open an issue or pull request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📜 License

This project is licensed under the MIT License — see the LICENSE file.


🙌 Acknowledgments

  • Inspired by the frustration of "port already in use" errors
  • Built using Cobra for CLI
  • Terminal UI powered by Bubbletea

🧑 Author

Arif Doğan

If you find this tool useful, please consider giving it a ⭐️ on GitHub!

Extension points exported contracts — how you extend this code

Finder (Interface)
Finder interface for finding processes [1 implementers]
internal/process/process.go

Core symbols most depended-on inside this repo

ErrorMsg
called by 9
internal/ui/ui.go
NewFinder
called by 5
internal/process/process.go
formatDuration
called by 4
internal/ui/ui.go
detectProject
called by 4
internal/process/process.go
processToRow
called by 3
internal/ui/bubbletea.go
View
called by 3
internal/ui/bubbletea.go
formatProject
called by 3
internal/ui/bubbletea.go
SuccessMsg
called by 3
internal/ui/ui.go

Shape

Function 34
Method 33
Struct 11
Interface 1

Languages

Go100%

Modules by API surface

internal/ui/bubbletea.go25 symbols
internal/ui/ui.go11 symbols
internal/process/process_linux.go11 symbols
internal/process/process_windows.go8 symbols
internal/process/process.go8 symbols
internal/process/process_darwin.go6 symbols
internal/config/config.go5 symbols
cmd/portfinder/main.go5 symbols

For agents

$ claude mcp add portfinder \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page