# Locked ports

> Who can open a Pod's public URL, how the lock on a public port works in the browser, and how to unlock a port when anyone should get in.

Source: https://docs.meshive.ai/documentation/endpoint-access/

Every port you open on a Pod has an **Access** setting in the **Endpoints** section:

| Access | Who can reach the port |
| --- | --- |
| **Internal** | Only Pods in the same workspace. The port has no URL. |
| **Public**, **Locked** | The port gets an HTTPS URL. Only **members of the workspace** in their browser, and **programs that send one of the port's [access keys](/documentation/endpoint-access-keys/)**, get through. Everyone else is turned away before the request reaches your app. |
| **Public**, **Unlocked** | The port gets an HTTPS URL, and **anyone who has the URL** can open it. Your app is the only thing that decides who gets in. |

A locked port protects any app — a web UI, a REST API, a notebook, a streaming or WebSocket server — even one that has no login of its own. Your app doesn't need to change. For CORS preflight, revoking browser sessions, workspace role permissions, limits, and troubleshooting, see [CORS, Sessions & Troubleshooting](/documentation/endpoint-access-controls/).

## New Pods start locked

When you create a Pod in the console, every **Public** port starts **Locked**. The switch sits next to the port's **Internal / Public** choice, both when you create a Pod and when you edit one.

| Where the port comes from | Starts as |
| --- | --- |
| A port you add, or a port you switch from Internal to Public | **Locked** |
| A Public port of a template | What the template's author chose for that port. When the author didn't choose — including every official template and templates made before locking existed — **Locked** |

The [SDK and CLI](/sdk-cli/) lock new public ports by default from **1.10.0**, and so does the hosted [MCP server](/sdk-cli/mcp/). Older SDK and CLI releases create public ports unlocked, as before.

> **Note — Pods you already have aren:**
> Locking doesn't touch Pods that existed before it. Their public ports stay open to anyone with the URL until you lock them. When a Pod has open ports that nobody has chosen to leave open, its **Connect** tab shows an orange notice — for example **2 ports are unlocked** — and you lock each port with the switch in its row. No restart is needed. A port you unlocked on purpose isn't counted.

## Opening a locked port in your browser

Use the URL as you always would — the **Connect** button on the Pod card, the link in the **Connect** tab, or a bookmark.

1. **The port sends you to the Meshive console.** If you aren't signed in to the console, sign in first.
2. **The console checks that you are a member** of the workspace that owns the Pod. Every role counts, **viewer** included.
3. **You land on the page you asked for.** The console shows **Opening …** for a moment and takes you back to the same path on the port.

Your browser then stays signed in to that port's URL for **7 days**. After that, opening the port goes through the console again; if you're still signed in to the console, it takes only a moment. Each port's URL has its own sign-in, so the first visit to another port goes through the console once too. If your console sign-in has expired, the console asks you to sign in first and then takes you back to the port.

If you aren't a member of the workspace, you see **This port is locked**: ask an admin of the workspace to invite you, then open the link again.

When a workspace admin removes a member, that member's browser sign-ins to the workspace's locked ports stop working within a few seconds. Members who stay are signed in again automatically, once, and may notice a brief reload.

### What the browser can and can't do

Signed-in browser access is meant for opening the port directly. Your app's own pages, links and WebSockets work as usual. To keep other websites from using your sign-in, a locked port refuses browser requests that come from a page on another address:

| Request from the browser | Locked port |
| --- | --- |
| Opening the URL, following a link to it, reloading | Works |
| Requests your app's own pages make to the same URL (fetch, forms, WebSockets) | Works |
| A page on another address — another website, or another port of the same Pod — calling the port with fetch, posting a form to it or opening a WebSocket to it | Refused |
| Showing the port inside an iframe on another page | Refused |
| A browser's CORS preflight (`OPTIONS`) request from a page on another address | Refused: it carries no sign-in. You can [allow preflight](/documentation/endpoint-access-controls/#web-pages-on-other-sites-allow-preflight) for a port |

These rules apply to browser sign-ins only. A program that sends an [access key](/documentation/endpoint-access-keys/) isn't affected by them. A web page on another address can't call a locked port with fetch even if it holds a key, because the browser's preflight request is refused, unless you turn on [Allow preflight](/documentation/endpoint-access-controls/#web-pages-on-other-sites-allow-preflight) for the port. If your app needs another port, or another site, to call this port, have a server-side program call it with an access key, turn on Allow preflight, or unlock the port.

If your sign-in ends while a page is open, the page's background requests start failing. Reload the page, or open the URL again, and you are taken through the console. A form you were submitting may show **Session expired** with a **Reconnect** link.

## Programs and scripts

A program can't sign in through the console. Give it an **access key** for the port and have it send the key with each request:

```bash
curl "$URL" -H "Authorization: Bearer $MESHIVE_ACCESS_KEY"
```

See [Access keys](/documentation/endpoint-access-keys/) for creating, rolling and revoking keys, and for apps that use the `Authorization` header themselves.

## Locking and unlocking a port

Lock or unlock a public port with the switch in its row: on the **Connect** tab of a running Pod, or in the **Endpoints** section when you create or edit a Pod. On the **Connect** tab the change applies within seconds and the Pod doesn't restart.

- **Unlocking asks first.** **Unlock port 3000?** — *Anyone with the URL will be able to open it. You can lock it again at any time.* Choose **Unlock**, or **Keep it locked**.
- **Unlocking keeps the port's access keys.** They aren't needed while the port is open, and they work again when you lock it again.
- **Locking needs no confirmation.** Programs that call the port without a key get `401` once the lock is in effect.

### While a change is being applied

A change takes a moment to reach the port's public address. During that time the row shows **Locking…** or **Unlocking…**, with a small spinner, instead of **Locked** or **Unlocked**. The row changes to **Locked** or **Unlocked** only after Meshive has confirmed that the change is in effect. This usually takes a few seconds, and you don't need to reload the page.

| Row says | Meaning |
| --- | --- |
| **Locking…** | You chose to lock the port, but it isn't confirmed yet. Until it is, the port can still be opened without signing in. |
| **Locked** | The lock is confirmed. Requests without a key or a console sign-in are turned away. |
| **Unlocking…** | You chose to unlock the port, but it isn't confirmed yet. For a little longer, requests without a key can still get `401`. |
| **Unlocked** | The port is open to anyone with the URL. |

If it takes longer than about 30 seconds, a line under the row says **Still applying the lock. Until it is applied, this port can be opened without signing in.** or **Still unlocking. Requests without a key can get 401 for a little longer.** The page keeps checking until the change is confirmed.

If you open a port in your browser just after you locked it, you may see **Applying the lock…** for a few seconds, with the text *This port was just locked. It opens as soon as the lock is in effect — usually a few seconds.* The page tries again by itself and opens the port when the lock is in effect. If that takes more than a minute, it shows *The lock is taking longer than usual to apply. Try again in a minute.* with a **Try again** button.

**CLI.** `meshive port-lock` and `meshive port-unlock` wait until the change is confirmed, for up to 60 seconds, and then print `access: Locked` or `access: Unlocked`. If it isn't confirmed in that time, they print `access: Locking…` or `access: Unlocking…` (and say whether the port may still be open); check again later with `meshive pod`. The command then ends with exit code `1`, so a script stops instead of going on with an unconfirmed lock. Add `--no-wait` to return at once without waiting; the exit code is then `0`, so check `state` with `--json` before you rely on the lock. `meshive pod` and `meshive pods` show the same **Locking…** and **Unlocking…** in the access column.

**API and MCP.** A port's `lockState` is one of `locked`, `locking`, `unlocked` or `unlocking`. Internal ports have none. The [MCP server](/sdk-cli/mcp/) reports the same values as `lock_state` in `pods`, and `set_port_lock` returns `state`. Treat only `locked` as confirmed.

Unlock a port only when you want everyone with the URL to reach it — for example a public demo, or an app that checks its own logins.

## What the template cards show

When you choose a template to create a Pod, a card with public ports shows how those ports will start. **Ports locked** means every public port starts locked. **1 port open** or **N ports open** means the template's author left that many public ports unlocked, so they start open to anyone with the URL. You can still change each port's lock before you create the Pod. A card without public ports shows nothing.

## Templates

When you create or edit a template, each **Public** port in **Endpoints** has the same **Locked** / **Unlocked** switch. It sets the starting value for Pods created from the template; whoever creates a Pod can still change it. New ports start **Locked**. Turning a template port to **Unlocked** shows *Anyone with the URL can open this port.* and doesn't ask for confirmation, because it doesn't open anything until someone creates a Pod.

## Changing a port later

| Change | What happens |
| --- | --- |
| **Rename** the port | Nothing changes: same URL, same lock, same keys. |
| **Change the port number** of a port that came with the template, to a number the Pod isn't using | Nothing changes: same URL, same lock, same keys, and browser sign-ins stay signed in. |
| **Change the port number** in any other way | The port gets a **new URL** if no port was using the new number. It keeps its Locked or Unlocked setting, but its access keys don't carry over — create new keys for the new port. Browser sign-ins go through the console once more. If another port was using that number, see the note below. |
| **Switch from Public to Internal** | The URL goes away, the lock is removed and **all of the port's access keys are revoked**. If you make it Public again later, it starts Locked in the console, with no keys. |
| **Switch from Internal to Public** | The port gets a URL and starts **Locked**, unless you unlock it. |

A URL, its access keys, and its browser sign-ins stay with the port number they were issued for. A port you added always gets a new URL when you change its number, and so does any port when the same edit switches the Pod to another template or version. If one edit swaps two ports' numbers, or moves a port onto a number another port had been using, the port that ends up on a number takes over that number's URL, keys, and sign-ins. Revoke those keys afterward if they shouldn't open the other app. To keep a template port's URL, change only its number, to one the Pod isn't using.

## What a lock covers

Locking applies to the **Public** ports of a Pod. **Internal** ports have no URL to lock. SSH access to a Pod, and the addresses of [serverless deployments](/serverless/serving/), aren't affected by it. Internal keeps other workspaces out; see [what a lock doesn't do](/documentation/endpoint-access-controls/#limits-to-know-about) for what the machine's operator can still reach.

## Next

- [CORS, Sessions & Troubleshooting](/documentation/endpoint-access-controls/) — Allow preflight, revoking browser sessions, role permissions, security limits, and error troubleshooting.
- [Access Keys](/documentation/endpoint-access-keys/) — create, roll, and revoke programmatic keys for locked ports.
