Random Port Generator
Generate random TCP/UDP port numbers in any range — well-known, registered, dynamic, or custom.
Common port reference
22
SSH
80
HTTP
443
HTTPS
3306
MySQL
5432
PostgreSQL
6379
Redis
27017
MongoDB
8080
HTTP-alt
8443
HTTPS-alt
TCP/UDP port ranges
Port numbers range from 0 to 65535. Ports 0–1023 are well-known ports assigned by IANA to common services (HTTP, HTTPS, SSH). Ports 1024–49151 are registered ports used by applications. Ports 49152–65535 are dynamic/ephemeral ports typically used for client-side connections. This tool generates cryptographically random port numbers using crypto.getRandomValues.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Picking a port for a local development server that is unlikely to be in use.
- Choosing a port in the dynamic range for a temporary service.
- Generating a port for a test that spins up a listener.
- Producing values to populate a config fixture.
- Avoiding a collision with a service you already have running.
Frequently Asked Questions
- Which port ranges are safe to use?
- 49152-65535, the IANA dynamic/private range reserved for exactly this. 0-1023 are well-known ports needing root on Unix; 1024-49151 are registered to specific services and may collide with something installed.
- What is the ephemeral port range?
- The range the OS draws from for outbound connections — commonly 32768-60999 on Linux and 49152-65535 on Windows. Binding a server inside it risks an intermittent conflict when the OS has already taken that port.
- Which ports should I avoid?
- Browsers block a list outright (including 25, 110, 143 and 6000) as ERR_UNSAFE_PORT, so a dev server there is unreachable from a browser regardless of whether it binds successfully.
- Why do the same dev ports keep recurring?
- Convention, not requirement: 3000 for Node, 8000 and 8080 for HTTP alternates, 5432 Postgres, 3306 MySQL, 6379 Redis. Their familiarity is exactly why they collide when several projects run at once.
- How do I check a port is actually free?
- This generates a number; it cannot test availability from a browser. Use lsof -i :PORT or netstat -an, or bind with port 0 and let the OS assign a free one — the only race-free method.
- Why does a port stay unusable after the process exits?
- Because the socket sits in TIME_WAIT for up to a couple of minutes, guaranteeing stray packets are not delivered to a new listener. `SO_REUSEADDR` is what lets a server rebind immediately.
- How do I get a guaranteed-free port in a test?
- Bind to port 0 and read back the one the OS assigned. Picking a random number and hoping is racy — another process can take it between the check and the bind.
Common errors and gotchas
- Picking a port below 1024, which needs elevated privileges on most systems.
- Choosing a well-known port and colliding with a service that is already listening.
- Assuming a random port is free, which only actually binding it can establish.
- Hard-coding a randomly chosen port into a config, which defeats the point of choosing dynamically.
- Overlooking that a firewall or a container may not expose the range you picked from.
Related Generators tools
UUID Generator
Generate secure v4 UUIDs.
QR Code Generator
Create customizable QR codes and export as SVG or PNG.
Lorem Ipsum
Generate placeholder paragraphs, sentences, or word lists.
Random Hex Generator
Generate cryptographically random hexadecimal strings.
Random Number String
Generate a random string of digits of any length.
Random String Generator
Generate random strings from a custom character set.
Random Color Generator
Generate random colors as HEX, RGB, and HSL.
MAC Address Generator
Generate random MAC addresses in several formats.