Safe defaults
Uses a high default range and avoids common service ports such as 3000, 5432, 6379, and 8080.
Generate a high, non-common, currently available port for Docker mappings and local development scripts.
npx safe-port
# 23456
PORT=$(npx safe-port)
docker run -p "$PORT:80" nginx
npx safe-port --count 3 --format json
Uses a high default range and avoids common service ports such as 3000, 5432, 6379, and 8080.
Choose plain, JSON, or environment output for Docker, CI, and shell scripts.
Run it with npx when you need it, then leave no global tool behind.