# Close a port

URL: https://heaven.dev/docs/reference/computers/port-remove
Updated: 2026-11-21

Close a published TCP port to new connections. Existing connections continue until they end or the service stops. For up to 30 days, adding the same Computer port can reclaim its old public port number.

`POST /v1/computer/modify`

## Parameters

- `computer` (string, required): Computer name or ID.
- `port` (string, required): Assigned public port to close. The Computer's TCP port can also identify it. An exact public port match takes precedence.

## Returns

- `data` (object, always present): The public port removed by this request.
  - `removed` (object, always present): Port's previous address and guest destination.
    - `address` (string, always present): Public connection address.
    - `computer_id` (string, always present): Computer ID.
    - `guest_port` (integer, always present): Destination port inside the Computer.
    - `name` (string, always present): Computer name.
    - `organization` (string): Computer's organization, when applicable. May be omitted.
    - `port` (integer, always present): Public port to connect to.
    - `published_at` (string (date-time), always present): When the port was published.

## Errors

Each code is explained in full at https://heaven.dev/docs/reference/errors.

| Code | Status | What happened |
|---|---:|---|
| `invalid` | 400 | An input is missing or invalid. |
| `unauthenticated` | 401 | The credential is missing, invalid, expired or revoked. |
| `denied` | 403 | The caller lacks permission for this action. |
| `not_found` | 404 | The resource is absent or inaccessible to this caller. |
| `conflict` | 409 | The request conflicts with the current resource state or an earlier request. |
| `over_capacity` | 409 | The request exceeds a resource or credential allowance. |
| `access_list_full` | 409 | The change would exceed the access-list allowance. |
| `payment_required` | 402 | Payment or credit is required. |
| `rate_limited` | 429 | The caller's request rate exceeds its limit. |
| `busy` | 429 | Too much work is in progress to accept this request. |
| `unknown` | 503 | The outcome is unconfirmed; a change may have happened. |
| `unavailable` | 503 | The service or requested feature is unavailable. |

## Notes

- API key permission: `port remove`.

## Examples

```sh tab="heaven CLI"
heaven port remove COMPUTER PORT
```

```sh tab="SSH"
ssh cli@heaven.dev port remove COMPUTER PORT
```

```sh tab="cURL"
curl https://heaven.dev/v1/computer/modify \
  -H "Authorization: Bearer $HEAVEN_API_KEY" \
  --json '{"action": "port remove", "computer": "my-site", "port": "26497"}'
```

```json tab="MCP"
{ "tool": "port_remove",
  "arguments": { "computer": "my-site", "port": "26497" } }
```

Response:

```json title="Response excerpt"
{
  "version": 1,
  "data": {
    "removed": {
      "address": "my-site.heaven.dev:26497",
      "computer_id": "3f1c9e2a-7b4d-4c8e-9a6f-2d5b8e1c7a90",
      "guest_port": 8080,
      "name": "my-site",
      "port": 26497,
      "published_at": "2026-11-16T12:00:00Z"
    }
  }
}
```
