⭐️ Your Star is very important for me!
A minimalist port occupier that aggressively holds TCP ports for testing and development purposes.
Perfect for reserving ports during CI/CD pipelines or local environment setup.
- Multi-port occupancy with comma-separated values
- Port range support using
start-end
syntax - Instant connection termination (RST packets)
- Graceful shutdown with
SIGINT/SIGTERM
handling - Connection monitoring with detailed logging
- Zero dependencies easy to use
# Install latest version
go install github.com/WolfYangFan/PortHog@latest
or use Github Actions Artifact
porthog -p PORT_SPEC
# Single port + range combination
porthog -p 8080,9000-9005,12345
# Development mode with debug logs
porthog -p 3000-3010 --level debug
2025/01/30 INFO PortHog started version=dev commit=unknown pid=114514
2025/01/30 INFO Port occupied successfully port=80
2025/01/30 INFO Received signal - initiating graceful shutdown... signal=interrupt
2025/01/30 DEBUG Closing listener port=80
2025/01/30 DEBUG Stopping listener port=80
2025/01/30 INFO Shutdown completed
- Uses raw TCP listeners with
SO_REUSEADDR
- Immediate connection reset (SO_LINGER=0)
- Background goroutine per port
graph TD
A[SIGINT/SIGTERM] --> B{Active Listeners?}
B -->|Yes| C[Close Listeners]
C --> D[Wait 5s Timeout]
D --> E[Force Exit]
B -->|No| E
- Fork this repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit changes (
git commit -m 'Add amazing feature'
) - Push to branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Please follow our Code of Conduct.
MIT License - see LICENSE for details.
"Hog those ports like there's no tomorrow!" 🐽💻