# Manage server ports

> Add, remove and label your server's ports, choose its primary address and publish a port on a floating IP.

Source: https://docs.coritan.com/managed-containers/ports/

In the dashboard:

- /dashboard/servers/…/ports: https://www.coritan.com/dashboard/servers

Every server has a *primary port*: the address players join. You can add more ports for a voice plugin, a map viewer, or a query or RCON listener. The server's **Ports** tab lists them, adds and releases them, and chooses which one is primary. With a [floating IP](/floating-ips/) attached, you can also open ports on that address and publish a port on the game's default port, so players join with the address alone.

## Before you begin

- The plan sets how many ports the server can hold, including the primary one. Most plans allow 5. The **Ports in use** figure on the tab shows how many you have used, such as `2 of 5`, and **Port slots** on the [Settings tab](/managed-containers/settings/) shows the limit.
- Extra ports on the machine's shared address come from the range 10000–40000. A plugin that should use one must be set to listen on that port number.
- On a server someone shared with you, you need the `allocation` permissions. The dashboard's permission list has no option for them, so the owner can grant them only [through the API](/managed-containers/users/#with-the-api).

## Read the Ports tab

The three figures at the top show the **Ports in use** against the plan's limit, the **Managed ports** that a feature added, and the **Primary address** with a button to copy it.

The table lists every port:

**Address**
: The address players or apps connect to, with a button to copy it. When a floating IP changes how the port is reached, the address on the machine's own IP shows under it as `direct`.

**Purpose**
: A **Primary** badge marks the primary port, **Managed** marks a port a feature added (such as [Bedrock crossplay](/managed-containers/software/bedrock-crossplay/)), and **Floating IP** marks a port on the server's floating IP. Other ports show what they are for, such as `Extra`, `Query` or `RCON`.

**Published on**
: The game's default port this port answers on, if you published it.

**Notes**
: The note you gave the port.

**Added**
: When the port was added.

Managed ports do not count against the plan's limit. You cannot release them; turning the feature off releases them.

## Add a port

1. In the [dashboard](https://www.coritan.com/dashboard/servers), go to **Container Apps** and open the server, then the **Ports** tab.
2. Select **Add port…**.
3. Choose where the port comes from:
   - **Lowest free port** takes the next free port in the machine's range.
   - **Choose a port** lets you pick one from the **Free port** list.
   - **On the floating IP** opens a port on the server's floating IP. Enter a **Port** from 1024 to 65535, or leave it empty for the first free one. The field's hint lists the ports the host itself uses, which you cannot open.
4. Optional: enter a **Note**, such as `voice` or `dynmap`, so you remember what the port is for. It can be up to 64 characters.
5. Select **Add port**.

The server listens on the new port the next time it starts, so restart it once the plugin is set up. Ports on the floating IP do not count against the plan's limit, and a server can hold up to 16 of them.

## Make another port primary

1. Open the menu at the end of the port's row and select **Make primary…**.
2. Select **Make primary**.

The server's main listener moves to that port, and it becomes the address the dashboard shows. If the server is running, we restart it so it listens on the new port. The menu does not offer this for managed ports.

## Publish a port on the default game port

With a floating IP attached, a port can answer on the game's default port, so players type the floating IP without a port number.

1. Open the menu at the end of the port's row and select **Publish on the default port…**.
2. Under **Publish on**, choose **Java (25565)** or **Bedrock (19132)**.
3. Select **Publish port**.

We move the port onto that number and restart the server if it is running. Only one port can hold each default port at a time. To undo it, open the menu, select **Change the published port…**, then **Stop publishing**. A managed port, or a port that is already on the floating IP, cannot be published.

## Release a port

1. Open the menu at the end of the port's row and select **Release port…**.
2. Select **Release port**.

Anything listening on the port stops being reachable. A port on the shared address goes back into the pool, and we may give it to another server. You cannot release the primary port or a managed port. While a floating IP is attached, the server keeps at least one port on the shared address, because it falls back to that port if the floating IP is detached.

## Give the server a web address

The **Web address** card at the bottom of the tab puts a hostname in front of the primary port, with an HTTPS certificate and our edge's filtering. Use it for a web map, a panel or an API.

1. Enter a **Hostname**, such as `map.example.com`. The field suggests a name when your account holds a Coritan domain.
2. Leave **Request an HTTPS certificate** selected unless you do not want one.
3. Select the button under the form to give the server a web address.

When we host the domain's DNS, we write the record for you. Otherwise, point the name at our edge yourself. The card then lists the address, and **Manage route** opens it in [Edge Proxy](/proxies/).

## Result

A message confirms each change, such as `Port 25567 added.`, `Port 25567 released.` or `25567 is now the primary port.` The table updates straight away.

## Troubleshooting

**Add port…** is greyed out
: Every port the plan allows is in use, and the server has no floating IP with room. Release a port, or move to a plan with more ports.

`Allocation limit reached (5). Cannot add more ports to this server.`
: The server holds every port its plan allows. Release a port first. The number in the message is your plan's limit.

`Port must be between 10000 and 40000`
: Ports on the shared address come from that range. Use **On the floating IP** for any other port.

`Port 25565 is reserved on the node main IP (gameproxy / platform services)`
: Our own services use that port on the shared address. Choose another port.

`Port 25567 is already in use on this node`
: Another server has that port. Choose another one from the **Free port** list.

`Cannot release the primary allocation`
: Make another port primary first, then release this one.

`This port is managed by the platform (…). Turn the feature that uses it off to release it.`
: A feature such as Bedrock crossplay uses the port. Turn the feature off to release it.

`Keep at least one shared node port: it is what this server falls back to if the floating IP is detached.`
: Keep this port while the floating IP is attached.

`Attach a floating IP first; …`
: Opening a port on a floating IP, or publishing on a default port, needs a floating IP attached to the server. See [Floating IPs](/floating-ips/).

`Another port on this server already publishes on 25565`
: Stop publishing the other port first.

## Related

- [Server settings and resources](/managed-containers/settings/)
- [Floating IPs](/floating-ips/)
- [Let Bedrock players join a Java server](/managed-containers/software/bedrock-crossplay/)

## With the API

`GET /api/v1/client/servers/{uuid}/allocations` lists the server's ports. Each has `id`, `ip`, `port`, `is_primary`, `purpose`, `label`, `managed`, `dedicated` (on the floating IP), `notes`, `publish_port` and `created_at`, and `endpoint`, the `host:port` players use.

`GET /api/v1/client/servers/{uuid}/allocations/rules` returns the limits: `allocation_limit` and `allocation_used` for the shared range, `publish_ip` (the floating IP, or `null`), and `dedicated_ip` with the floating IP's `address`, `port_min`, `port_max`, `reserved_ports`, `limit` and `used`, or `null` without one. `game` names the server's game and its `default_port`.

`GET /api/v1/client/servers/{uuid}/allocations/available-ports` returns up to `limit` free ports in the shared range (1 to 200, default 50) as `ports`.

Add a port. Leave out `port` for the lowest free one, and set `on_dedicated_ip` to `true` to open it on the floating IP:

```bash
curl -X POST https://api.coritan.com/api/v1/client/servers/$SERVER/allocations \
  -H "Authorization: Bearer $CORITAN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"port": 25567, "notes": "voice"}'
```

The response is `201` with the new port.

| Request | What it does |
| --- | --- |
| `DELETE /allocations/{allocation_id}` | Releases the port. |
| `POST /allocations/{allocation_id}/primary` | Makes the port primary. The response adds a `publish` object. |
| `POST /allocations/{allocation_id}/publish-port` | Publishes the port on `{"port": 25565}` or `{"port": 19132}`, or stops with `{"port": null}`. Returns `allocation` and `publish`. |

The paths are relative to `/api/v1/client/servers/{uuid}`. In `publish`, `restart` is `scheduled` when we restart the server to rebind it. Every refusal answers `400` with the reason in `detail`.

On a server shared with you, listing needs `allocation.read`, adding needs `allocation.create`, releasing needs `allocation.delete`, and making a port primary or publishing it needs `allocation.update`.

## API

- `GET /api/v1/client/servers/{uuid}/allocations`: List primary + extra ports for this server (https://docs.coritan.com/api/reference/client/container-apps/servers-allocations/#op-get-api-v1-client-servers-uuid-allocations)
- `POST /api/v1/client/servers/{uuid}/allocations`: Create server allocation (https://docs.coritan.com/api/reference/client/container-apps/servers-allocations/#op-post-api-v1-client-servers-uuid-allocations)
- `GET /api/v1/client/servers/{uuid}/allocations/available-ports`: Free ports on this server's node (node-wide, not shared across servers) (https://docs.coritan.com/api/reference/client/container-apps/servers-allocations/#op-get-api-v1-client-servers-uuid-allocations-available-ports)
- `GET /api/v1/client/servers/{uuid}/allocations/rules`: Allocation rules (https://docs.coritan.com/api/reference/client/container-apps/servers-allocations/#op-get-api-v1-client-servers-uuid-allocations-rules)
- `DELETE /api/v1/client/servers/{uuid}/allocations/{allocation_id}`: Release an extra port (https://docs.coritan.com/api/reference/client/container-apps/servers-allocations/#op-delete-api-v1-client-servers-uuid-allocations-allocation-id)
- `POST /api/v1/client/servers/{uuid}/allocations/{allocation_id}/primary`: Mark an existing port as the primary allocation (https://docs.coritan.com/api/reference/client/container-apps/servers-allocations/#op-post-api-v1-client-servers-uuid-allocations-allocation-id-primary)
- `POST /api/v1/client/servers/{uuid}/allocations/{allocation_id}/publish-port`: Set allocation publish port (https://docs.coritan.com/api/reference/client/container-apps/servers-allocations/#op-post-api-v1-client-servers-uuid-allocations-allocation-id-publish-port)
