Random Port Generator
Technical details
How the Random Port Generator Works
What the Tool Does
The Random Port Generator picks one or more TCP/UDP port numbers from the requested IANA range using crypto.getRandomValues() with unbiased rejection sampling. By default it avoids both well-known ports and a curated list of widely-used development ports (3000, 8080, 5432, 6379, etc.) so the generated numbers are immediately usable for new local services.
Common Developer Use Cases
Developers spinning up new microservices, docker-compose stacks, or ephemeral test environments use the tool to choose conflict-free ports without thinking. SREs allocate ports for new internal services without manually scanning IANA tables. The 'ephemeral' range is ideal for client-side TCP test harnesses that need short-lived sockets matching production kernel behaviour.
Data Formats, Types, or Variants
Three predefined ranges are available: Well-known (1–1023), Registered / Unprivileged (1024–49151), and Dynamic / Ephemeral (49152–65535). Each generated number is annotated with its classification. The avoid-common-ports list covers HTTP/HTTPS, SSH, common database ports, common dev servers, message queues, and standard cache services.
Common Pitfalls and Edge Cases
Random port allocation does not check whether the port is actually free on your machine — that requires an OS-level bind attempt. The 'avoid common ports' list is curated, not exhaustive; some industry-specific defaults (Cassandra 9042, Elasticsearch 9300, etc.) are flagged but custom internal services may still clash. Generate a fresh batch if the first pick conflicts with something local.
When to Use This Tool vs Code
Use the browser tool when configuring a one-off service or writing a sample. In automation, prefer asking the OS to assign a port (bind to port 0 and read back the chosen value) — this guarantees the port is actually free and avoids any race between random selection and bind.