Each port of your VM gets an HTTPS web address, so a server you run there opens in a browser. A port starts closed: only members of your organization reach it, and you open it to share a link or make it public.
Open a port
Section titled “Open a port”Opening a port gives it an access level. authenticated accepts members and anyone with a link you make; public accepts anyone. Opening a port with the access it already has changes nothing and keeps its links.
The samples use a VM named web with a web server on port 3000. VMs shows how to create the VM.
- Open the dashboard and select
web. - Select the Ports tab.
- Select Add port.
- Enter
3000in Port. - Choose Members and links in Access.
- Select Add port.
The first command starts a web server in web and prints its job number. The second opens port 3000 to members and links.
si job start -c 'cd /tmp && python3 -m http.server 3000' websi port open web 3000 --auth1port 3000: authenticatedcurl -sS -X PUT "https://api.slashinfra.com/svms/web/ports/3000" \ -H "Authorization: Bearer $SI_API_KEY" -H "Content-Type: application/json" \ -d '{"access":"authenticated"}'API reference: Control API operation
{"port":3000,"access":"authenticated","url":"https://3000-6f1c0f0e8a.slashinfra.dev/?si_access=..."}import os, requests
res = requests.put( "https://api.slashinfra.com/svms/web/ports/3000", headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"}, json={"access": "authenticated"},)res.raise_for_status()print(res.json()["port"], res.json()["access"])3000 authenticatedconst res = await fetch('https://api.slashinfra.com/svms/web/ports/3000', { method: 'PUT', headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ access: 'authenticated' }),})if (!res.ok) throw new Error(await res.text())const port = (await res.json()) as { port: number; access: string }console.log(port.port, port.access)3000 authenticatedUse the address from a client
Section titled “Use the address from a client”Port 3000 of VM web has the address https://3000-<id>.slashinfra.dev, where <id> is the VM’s id. For a VM with id 6f1c0f0e8a, that is https://3000-6f1c0f0e8a.slashinfra.dev.
On a preview host, send the API key in X-Si-Authorization, because the app keeps Authorization for itself. SlashInfra removes the header before the request reaches the VM.
A link adds ?si_access= with a token. The first GET to a link answers 303 without the token and sets an access cookie, so a client that follows a link must keep cookies. A request that passes the access check wakes a sleeping VM. If the VM declares a readiness port, a request that waits on a wake is released when that port answers; set readiness on VMs. See Sleep and wake.
curl -sS -o /dev/null -w '%{http_code}\n' \ -H "X-Si-Authorization: Bearer $SI_API_KEY" \ "https://3000-6f1c0f0e8a.slashinfra.dev/"200List ports
Section titled “List ports”List returns every open port of the VM with its access and a fresh link for each authenticated port. A port that is not in the list is closed; a public port has url as null.
- Open the dashboard and select
web. - Select the Ports tab. The table lists each port under Port and its level under Who can open it.
si port ls webport access url3000 authenticated https://3000-6f1c0f0e8a.slashinfra.dev/?si_access=...curl -sS "https://api.slashinfra.com/svms/web/ports" \ -H "Authorization: Bearer $SI_API_KEY"API reference: Control API operation
[{"port":3000,"access":"authenticated","url":"https://3000-6f1c0f0e8a.slashinfra.dev/?si_access=..."}]import os, requests
res = requests.get( "https://api.slashinfra.com/svms/web/ports", headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},)res.raise_for_status()for port in res.json(): print(port["port"], port["access"])3000 authenticatedconst res = await fetch('https://api.slashinfra.com/svms/web/ports', { headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` },})if (!res.ok) throw new Error(await res.text())const ports = (await res.json()) as { port: number; access: string }[]for (const port of ports) console.log(port.port, port.access)3000 authenticatedMake a presigned link
Section titled “Make a presigned link”A link opens one port of one VM until it expires. The life is 3600 seconds by default and 2592000 seconds (30 days) at most on both plans. A link works for a public port too, but a public port needs none.
- Open the dashboard and select
web. - Select the Ports tab.
- Choose 7 days in Link lifetime.
- Select Copy link on the
3000row. The link is on your clipboard.
si port url web 3000 --ttl 7dhttps://3000-6f1c0f0e8a.slashinfra.dev/?si_access=...curl -sS -X POST "https://api.slashinfra.com/svms/web/ports/3000/url" \ -H "Authorization: Bearer $SI_API_KEY" -H "Content-Type: application/json" \ -d '{"ttl_s":604800}'API reference: Control API operation
{"url":"https://3000-6f1c0f0e8a.slashinfra.dev/?si_access=...","expires_at":1796562568000}import os, requests
res = requests.post( "https://api.slashinfra.com/svms/web/ports/3000/url", headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"}, json={"ttl_s": 604800},)res.raise_for_status()print(res.json()["url"])https://3000-6f1c0f0e8a.slashinfra.dev/?si_access=...const res = await fetch('https://api.slashinfra.com/svms/web/ports/3000/url', { method: 'POST', headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ ttl_s: 604800 }),})if (!res.ok) throw new Error(await res.text())const link = (await res.json()) as { url: string }console.log(link.url)https://3000-6f1c0f0e8a.slashinfra.dev/?si_access=...Rotate the links
Section titled “Rotate the links”Rotate makes a new generation of an open port. Every link to an authenticated port that was minted before the rotate stops working: a request with that link answers 401, including links you already shared. The port keeps its access, and the reply carries a fresh link when the port is authenticated.
- Open the dashboard and select
web. - Select the Ports tab.
- Select More actions on the
3000row, then Rotate links. The dashboard saysEvery link of port 3000 was invalidated.
si port rotate web 3000rotated every link of port 3000The command prints no link. si port ls or si port url shows the current one.
curl -sS -X POST "https://api.slashinfra.com/svms/web/ports/3000/rotate" \ -H "Authorization: Bearer $SI_API_KEY"API reference: Control API operation
{"port":3000,"access":"authenticated","url":"https://3000-6f1c0f0e8a.slashinfra.dev/?si_access=..."}import os, requests
res = requests.post( "https://api.slashinfra.com/svms/web/ports/3000/rotate", headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},)res.raise_for_status()print(res.json()["url"])https://3000-6f1c0f0e8a.slashinfra.dev/?si_access=...const res = await fetch('https://api.slashinfra.com/svms/web/ports/3000/rotate', { method: 'POST', headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` },})if (!res.ok) throw new Error(await res.text())const port = (await res.json()) as { url: string }console.log(port.url)https://3000-6f1c0f0e8a.slashinfra.dev/?si_access=...Change who can open it
Section titled “Change who can open it”Open the port again with the other access. The change makes a new generation, so every link shared before the change loses its access. A public address needs no link, so the page still opens; an authenticated port needs a new link. The dashboard sets the access when you add a port and has no control to change it later.
si port open web 3000 --publicport 3000: publiccurl -sS -X PUT "https://api.slashinfra.com/svms/web/ports/3000" \ -H "Authorization: Bearer $SI_API_KEY" -H "Content-Type: application/json" \ -d '{"access":"public"}'API reference: Control API operation
{"port":3000,"access":"public","url":null}import os, requests
res = requests.put( "https://api.slashinfra.com/svms/web/ports/3000", headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"}, json={"access": "public"},)res.raise_for_status()print(res.json()["access"])publicconst res = await fetch('https://api.slashinfra.com/svms/web/ports/3000', { method: 'PUT', headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ access: 'public' }),})if (!res.ok) throw new Error(await res.text())console.log(((await res.json()) as { access: string }).access)publicPass --auth or send authenticated to return the port to members and links.
Close a port
Section titled “Close a port”Closing a port makes it closed: only members reach it, and every link of the port stops working at once, even after you open the port again. Closing an already closed port changes nothing.
- Open the dashboard and select
web. - Select the Ports tab.
- Select More actions on the
3000row. - Select Delete. The dashboard offers Undo for 5 seconds, then closes the port.
si port close web 3000closed port 3000 of SVM "web"curl -sS -i -X DELETE "https://api.slashinfra.com/svms/web/ports/3000" \ -H "Authorization: Bearer $SI_API_KEY"API reference: Control API operation
HTTP/2 204...import os, requests
res = requests.delete( "https://api.slashinfra.com/svms/web/ports/3000", headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},)res.raise_for_status()print(res.status_code)204const res = await fetch('https://api.slashinfra.com/svms/web/ports/3000', { method: 'DELETE', headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` },})if (!res.ok) throw new Error(await res.text())console.log(res.status)204Forward a port to your laptop
Section titled “Forward a port to your laptop”A forward listens on 127.0.0.1 on your laptop and carries each connection to a port of the VM. It uses your key, not the web address, so it works on a closed port, and the first connection wakes the VM. A forward counts toward the VM’s connection limit. Ctrl-C closes every forward.
si port forward web 3000127.0.0.1:3000 -> SVM 6f1c0f0e8a:3000Ctrl-C closes every forwardsi port forward web 3000 8000 5432:15432 forwards three ports; 5432:15432 listens on local port 15432 and reaches VM port 5432. --stdio carries one port between standard input and output for an SSH ProxyCommand; see SSH.
Options
Section titled “Options”| Field | Type | Default | Allowed values | What it changes |
|---|---|---|---|---|
ref (path, <SVM>) |
string | Required | A VM name, or its id | The VM whose port the request acts on. |
port (path, <PORT>) |
integer | Required | 1 to 65535 | The port on the VM. |
project (--project) |
string | default |
A project name, or its proj_ id |
The project that holds the VM. |
access (--auth, --public) |
string | Required | authenticated or public; the CLI opens authenticated unless you pass --public |
Who may open the address. |
ttl_s (--ttl) |
number | 3600 |
1 to 2592000 whole seconds (30 days); the CLI takes 30m, 1h, 7d or seconds |
The life of the link. |
ports (<PORT[:LOCAL]>) |
string | Required | PORT from 1 to 65535, and LOCAL from 1 to 65535 when given |
The ports to forward and the local ports where they listen. |
Scroll horizontally to see all columns.
States
Section titled “States”| State | What it means for you | What you can do |
|---|---|---|
closed (default) |
Only members of the organization open the address. | Open the port to share a link or make it public. |
authenticated |
Members and anyone with a link you make open the address. | Copy a link, rotate it, change the access, or close the port. |
public |
Anyone with the address opens it; no link or key. | Treat the content as public, change the access, or close it. |
Scroll horizontally to see all columns.
Errors
Section titled “Errors”| Code | When | Fix |
|---|---|---|
invalid_port |
Any operation names a port outside 1 to 65535. | Send a port from 1 to 65535. |
invalid_access |
Open sends an access other than authenticated or public. |
Send authenticated or public. |
invalid_ttl |
The link life is not a whole number from 1 to 2592000 seconds. | Send seconds in that range, or use --ttl 7d. |
public_ports_not_allowed |
The plan does not include public ports. | Open the port as authenticated. |
port_limit |
Open would make more than 50 open ports on the VM. | Close a port first. |
port_closed |
A request to make a link or rotate names a port that is not open. | Open the port first. |
not_supported_by_image |
The port is 22 or 6080 and the image lacks SSH or the desktop. | Use the default image. |
Scroll horizontally to see all columns.
Errors that any request can return are in the error catalog.
Permissions
Section titled “Permissions”| Operation | Who can | Key action |
|---|---|---|
| Open a port | Any member | svm:write |
| List ports | Any member | svm:read |
| Make a presigned link | Any member | svm:read |
| Rotate the links | Any member | svm:write |
| Change who can open it | Any member | svm:write |
| Close a port | Any member | svm:write |
| Forward a port | Any member | svm:read |
Scroll horizontally to see all columns.
Limits
Section titled “Limits”- A VM has at most 50 open ports on both plans. An open above that answers 409
port_limit. - A port is a number from 1 to 65535.
- A link lasts one hour by default and 30 days at most on both plans.
- A link names one VM and one port; it does not authenticate another port.
- A VM accepts 64 preview connections at once; more answer 429.
- A preview connection closes after about 100 seconds without traffic.
- Port 22 and port 6080 need the default image; a postgres VM answers 409
not_supported_by_image.
The full list is in Limits.
- Who can reach your VM: members, keys and the link access levels.
- Sleep and wake: a request to a web address wakes a sleeping VM.
- Services: keep the server running across a sleep.