Skip to main content

Connect With TLS

If you enabled TLS (SSL) on your database, then you need to configure your client too. When you click on Connect button, you can copy the code that is required for your client. Also, below you can find example client configurations with TLS enabled. If you are using a Redis client that is not listed below, please check the documentation of your client.

Node.js#

Library: ioredis

Example:

const Redis = require("ioredis");
let client = new Redis("rediss://:YOUR_PASSWORD@YOUR_ENDPOINT:YOUR_PORT");await client.set('foo', 'bar');let x = await client.get('foo');console.log(x);

Python#

Library: redis-py

Example:

import redisr = redis.Redis(host= 'YOUR_ENDPOINT',port= 'YOUR_PORT',password= 'YOUR_PASSWORD', ssl=True)r.set('foo','bar')print(r.get('foo'))

Java#

Library: jedis

Example:

Jedis jedis = new Jedis("YOUR_ENDPOINT", "YOUR_PORT", true);jedis.auth("YOUR_PASSWORD");jedis.set("foo", "bar");String value = jedis.get("foo");System.out.println(value);

GoLang#

Library: redigo

Example:

func main() {  c, err := redis.Dial("tcp", "YOUR_ENDPOINT:YOUR_PORT", redis.DialUseTLS(true))  if err != nil {      panic(err)  }
  _, err = c.Do("AUTH", "YOUR_PASSWORD")  if err != nil {      panic(err)  }
  _, err = c.Do("SET", "foo", "bar")  if err != nil {      panic(err)  }
  value, err := redis.String(c.Do("GET", "foo"))  if err != nil {      panic(err)  }
  println(value)}