Skip to content

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.

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.

  1. Open the dashboard and select web.
  2. Select the Ports tab.
  3. Select Add port.
  4. Enter 3000 in Port.
  5. Choose Members and links in Access.
  6. Select Add port.

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.

Terminal window
curl -sS -o /dev/null -w '%{http_code}\n' \
-H "X-Si-Authorization: Bearer $SI_API_KEY" \
"https://3000-6f1c0f0e8a.slashinfra.dev/"
Output
200

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.

  1. Open the dashboard and select web.
  2. Select the Ports tab. The table lists each port under Port and its level under Who can open it.

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.

  1. Open the dashboard and select web.
  2. Select the Ports tab.
  3. Choose 7 days in Link lifetime.
  4. Select Copy link on the 3000 row. The link is on your clipboard.

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.

  1. Open the dashboard and select web.
  2. Select the Ports tab.
  3. Select More actions on the 3000 row, then Rotate links. The dashboard says Every link of port 3000 was invalidated.

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.

Terminal window
si port open web 3000 --public
Output
port 3000: public

Pass --auth or send authenticated to return the port to members and links.

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.

  1. Open the dashboard and select web.
  2. Select the Ports tab.
  3. Select More actions on the 3000 row.
  4. Select Delete. The dashboard offers Undo for 5 seconds, then closes the port.

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.

Terminal window
si port forward web 3000
Output
127.0.0.1:3000 -> SVM 6f1c0f0e8a:3000
Ctrl-C closes every forward

si 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.

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.

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.

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.

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.

  • 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.