Introduction
Connect to a local instance of Redis
The prompt indicates a connection to a Redis instance hosted locally (127.0.0.1
) and accessed over Redis's default port (6739
)
Connect to a remote instance of Redis
If you’ve set a Redis password, clients will be able to connect to Redis even if they don’t include the -a
flag in their redis-cli
command. However, they won’t be able to add, change, or query data until they authenticate.
To authenticate after connecting, use the auth
command followed by the password:
If you’re working with a managed Redis database, your cloud provider may give you a URI that begins with redis://
or rediss://
which you can use to access your datastore.
If the connection string begins with
redis://
, you can include it as an argument toredis-cli
to connect.However, if you have a connection string that begins with
rediss://
, that means your managed database requires connections over TLS/SSL.redis-cli
does not support TLS connections, so you’ll need to use a different tool that supports therediss://
protocol in order to connect with the URI.For Managed Databases, which require connections to be made over TLS, Redli to access the Redis instance.
-tls
option : specifies that the connection should be made over TLS-u
flag : for connection URI
If an attempt to connect to an unavailable instance, redis-cli will go into disconnected mode.
Testing Connection
Disconnecting from Redis
Both quit
and exit
will close the connection, but only as soon as all pending replies have been written to clients.
Last updated