I found the Redis 6 add-on by Heroku generated an Error: self signed certificate in certificate chain
error when when connecting to REDIS_URL without any parameters with ioredis on Node. You can avoid this error by passing in TLS options with rejectUnauthorized
set to false
.
The rejectUnauthorized
of false
allows for self-signed certificates, which would be an issue if concerned about MITM attacks. See TLS options for more background.
This is working for me with the latest ioredis
package with rediss:// and redis:// URL's...
const REDIS_URL = process.env.REDIS_URL;
const redis_uri = url.parse(REDIS_URL);
const redisOptions = REDIS_URL.includes("rediss://")
? {
port: Number(redis_uri.port),
host: redis_uri.hostname,
password: redis_uri.auth.split(":")[1],
db: 0,
tls: {
rejectUnauthorized: false,
},
}
: REDIS_URL;
const redis = new Redis(redisOptions);