Using redis-cli
Connect to your Upstash Redis database with redis-cli. Learn how to install it, connect over TLS, run commands, and when to use TCP versus HTTP.
redis-cli is the command line interface that ships with the official Redis
distribution. Because Upstash speaks the native Redis protocol over TCP, you can
use redis-cli to connect to your Upstash database and run any Redis command
directly from your terminal.
Upstash exposes your database over both TCP and HTTP. redis-cli and other
traditional clients use the TCP (RESP) protocol, while the HTTP/REST API and
@upstash/redis SDK are built for
serverless environments. This page covers the TCP path with redis-cli.
Install redis-cli
redis-cli is included in the official Redis distribution. If you don't have
Redis installed, follow the
Redis installation guide.
Get your connection details
Open your database in the Upstash Console and go to the Details tab. You will need the Endpoint, Port, and the Password (token) of your database.
The Details tab has a ready-to-use redis-cli command with your endpoint,
port, and password already filled in. You can copy it and paste it straight
into your terminal.
Connect
Upstash enables TLS on every database, so you must pass the --tls flag when
connecting with redis-cli:
> redis-cli --tls -a PASSWORD -h ENDPOINT -p PORTENDPOINT:PORT> set counter 0OKENDPOINT:PORT> get counter"0"ENDPOINT:PORT> incr counter(int) 1ENDPOINT:PORT> incr counter(int) 2You can also connect using a single rediss:// connection string (note the
double s, which signals TLS):
> redis-cli -u rediss://default:PASSWORD@ENDPOINT:PORTTLS is enabled by default for all Upstash Redis databases and cannot be
disabled. If you omit --tls (or use redis:// instead of rediss://), the
connection will fail.
TCP or HTTP?
Upstash serves the same database over two protocols, so you can pick whichever fits your environment:
- TCP (RESP) — Use
redis-cliand standard Redis clients such asioredis,redis-py, orjedis. This is the right choice for local development, scripting, and long-running servers. - HTTP/REST — Use the @upstash/redis SDK or the REST API. This is the right choice for serverless platforms like Vercel and Cloudflare Workers, where TCP-based clients can run into connection limits.
For connecting via the official SDKs and other language clients, see Connect Your Client.