Port Assignment

How Exposr assigns public ports for tunnels.

Automatic assignment

When no public port is specified, Exposr automatically assigns one:

  1. First, try port 25565
  2. If taken, pick a random port from 20000–30000
  3. Send the port to the server for registration verification
  4. If the server confirms it's available, use it
  5. If not, try another random port (up to 100 attempts)
bash
# Automatic port assignment
exposr expose 3000

Explicit assignment

You can request a specific public port with the to keyword. Exposr requests that exact port without fallback:

bash
# Request specific public port 21342
exposr expose 3000 to 21342

Assignment algorithm

text
25565
  |
  v
available?
  |
  +-- yes -> register tunnel
  |
  +-- no
        |
        v
random port from 20000-30000
        |
        v
available?
  |
  +-- yes -> register tunnel
  |
  +-- no -> try another random port (up to 100 attempts)

Random ports are verified with the server — a port is not assumed available just because it was randomly selected.