By skaniras
I have a Parse Server (which is a Node.js server basically) and I’m trying to connect to a redis database, which is hosted on DigitalOcean Managed Databases. Both servers are on the same VPC network and the droplet is added to redis’s accepted incoming connections.
Here’s the code on my parse server:
const redis = require("redis")
const redisClient = redis.createClient({
url: "rediss://username:password@private-db-redis-fra1-...db.ondigitalocean.com:25061"
})
The connection string is generated by DigitalOcean. The droplet’s outbound traffic rules are open
Here are my error logs:
2|index | AbortError: Ready check failed: Redis connection lost and command aborted. It might have been processed.
2|index | at RedisClient.flush_and_error (/root/parse-server-example/node_modules/redis/index.js:362:23)
2|index | at RedisClient.connection_gone (/root/parse-server-example/node_modules/redis/index.js:664:14)
2|index | at Socket.<anonymous> (/root/parse-server-example/node_modules/redis/index.js:293:14)
2|index | at Object.onceWrapper (events.js:313:30)
2|index | at emitNone (events.js:111:20)
2|index | at Socket.emit (events.js:208:7)
2|index | at endReadableNT (_stream_readable.js:1064:12)
2|index | at args.(anonymous function) (/usr/lib/node_modules/pm2/node_modules/event-loop-inspector/index.js:138:29)
2|index | at _combinedTickCallback (internal/process/next_tick.js:139:11)
2|index | at process._tickDomainCallback (internal/process/next_tick.js:219:9)
Any idea what I’m doing wrong?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hello,
When connecting to DigitalOcean Managed Redis, you need to use the rediss protocol because it requires connections to be made over TLS.
To connect using the redis package with TLS, follow the example below:
const Redis = require('redis');
const host = 'db-redis.db.ondigitalocean.com';
const port = '25061';
const username = 'user';
const password = 'secret';
const url = `rediss://${username}:${password}@${host}:${port}`;
const client = Redis.createClient({
url: url,
tls: {}
});
client.on('error', (err) => {
console.error('Redis Client Error', err);
});
(async () => {
try {
await client.connect();
console.log('Connected to Redis');
} catch (err) {
console.error('Error connecting to Redis', err);
}
})();
If you are using sockets and need to enable rediss, pass the necessary options through adapterOptions:
sockets: {
onlyAllowOrigins: ['https://my-website.com'],
adapterOptions: {
user: 'username',
pass: 'password',
host: 'host',
port: 9999,
db: 2, // pick a number
tls: {},
},
adapter: '@sailshq/socket.io-redis',
},
For session management, pass the tls: {} empty object in the configuration:
session: {
pass: 'password',
host: 'host',
port: 9999,
db: 1, // pick a number not used by sockets
tls: {},
cookie: {
secure: true,
maxAge: 24 * 60 * 60 * 1000, // 24 hours
},
},
Basically, by including the tls: {} option, you make sure that your connection to the Redis instance uses TLS, providing the necessary security for your application.
- Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
