CLI & APICommand reference
stackblaze connect
Open an interactive database shell (psql, mysql, or redis-cli); [addon] = postgres, mysql or redis, optional when the app has exactly one database addon
Usage: stackblaze connect [options] [addon]
Open an interactive database shell (psql, mysql, or redis-cli); [addon] =
postgres, mysql or redis, optional when the app has exactly one database addon
Options:
--api-url <url> StackBlaze API base URL (env STACKBLAZE_API_URL)
--token <token> API token, sb_pat_... (env STACKBLAZE_TOKEN)
-p, --project <name> Project name
-e, --env <name> Environment name (default: production)
-a, --app <name> App name
--instance <name> Addon instance when multiple match
--local Run the client on this machine through a private tunnel
(needs psql/mysql/redis-cli installed) (default: false)
--tunnel Keep a private tunnel open for GUI tools and print
host/port/user/database (default: false)
--port <port> Local port for --local/--tunnel (default: a free port)
--print-only Open the private tunnel and print its connection string
instead of launching a client (tunnel stays open until
Ctrl-C) (default: false)
-h, --help Print help
Modes:
stackblaze connect postgres psql runs inside the app pod (default)
stackblaze connect postgres --local psql runs here, via a private tunnel
stackblaze connect postgres --local --port 15432 --print-only
print postgresql://…@127.0.0.1:15432/…
stackblaze connect redis --tunnel keep 127.0.0.1:<port> open for GUI tools
The tunnel never exposes the database publicly: each local TCP connection is
carried over an authenticated WebSocket to the StackBlaze API, which
port-forwards it to the addon pod. It listens on 127.0.0.1 only, closes after
30 minutes idle, and Ctrl-C closes it. Requires app write access.
--local, --tunnel and --print-only may be disabled by your platform admin.Example
Open psql on your machine against the app's PostgreSQL add-on, through a private tunnel (the app's image has no psql, so the default in-pod mode can't be used). Here it creates a table, adds a row and reads it back.
PAGER=cat PSQL_PAGER=cat stackblaze connect postgres --local -p github-demo-cw8z -e dev -a hello-webTunnel 127.0.0.1:41963 → postgres addon "hello-web-qw6y-postgresql-s32l". Running local psql…
psql (14.24 (Ubuntu 14.24-0ubuntu0.22.04.1), server 17.5 (Debian 17.5-1.pgdg110+1))
WARNING: psql major version 14, server major version 17.
Some psql features might not work.
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.
app=# create table if not exists signups (email text, created date default current_date);
CREATE TABLE
app=# insert into signups values ('ada@example.com');
INSERT 0 1
app=# select * from signups;
email | created
-----------------+------------
ada@example.com | 2026-11-25
(1 row)
app=# \qWithout --local, psql runs inside the app's pod, and the CLI says so when the image doesn't have it:
stackblaze connect postgres -p github-demo-cw8z -e dev -a hello-webConnecting to postgres addon "hello-web-qw6y-postgresql-s32l" via hello-web-qw6y-web-59c674b9c6-f8jsk/web…
sh: exec: line 0: psql: not found
x The postgres client is not installed in the app's image. Run it on this machine instead: stackblaze connect postgres --local (or --tunnel for GUI tools).