Connect a client
Connect to a Database with any standard Valkey or Redis client through the shared gateway. Use these connection details:
- Host: the region's RESP endpoint (shared by Databases in that region)
- Port:
6379(default) with TLS - Username: your Database name
- Password: a Momento API token
Retrieve the RESP endpoint for a Database from the Momento console. Open Capacity Pools,
select a Pool, and open its Databases tab. Copy the account-visible RESP endpoint shown there.
The CLI command database describe may also display a sample connection command with the RESP
endpoint.
Check Valkey compatibility to understand which RESP commands are supported. Below are examples with some of the most common Redis and Valkey clients.
valkey-cli
valkey-cli --tls \
-h <endpoint> \
--user <database-name> \
--pass <api-token>
The Valkey CLI can also read your VALKEYCLI_AUTH environment variable, for example:
VALKEYCLI_AUTH=<api-token> \
valkey-cli --tls \
-h <endpoint> \
--user <database-name>
Node.js (ioredis)
import Redis from "ioredis";
const client = new Redis({
host: "<endpoint>",
port: 6379,
tls: {},
username: "<database-name>",
password: "<api-token>",
});
Python (redis-py)
import redis
client = redis.Redis(
host="<endpoint>",
port=6379,
ssl=True,
username="<database-name>",
password="<api-token>",
)
Go (go-redis)
client := redis.NewClient(&redis.Options{
Addr: "<endpoint>:6379",
TLSConfig: &tls.Config{},
Username: "<database-name>",
Password: "<api-token>",
})