node-redis: URL not working.
Issue
import { RedisClient } from 'redis'
new RedisClient({
url: "redis://rediscloud:pass@redis-ttt.ttt.eu-central-1-1.ec2.cloud.redislabs.com:13180"
});
Why is this not working? It’s giving me this error: Error: Redis connection to 127.0.0.1:6379 failed
Environment
- Node.js Version:
v12.14.1
- Redis Version:
4.0.9
- Platform: Windows 10 & Ubuntu
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 7
- Comments: 19 (1 by maintainers)
I connected mine like this:
import { createClient } from “redis”;
const redis = createClient({ url:
redis://${process.env.REDIS_HOST}:${process.env.REDIS_PORT}, });@supertiger1234 instead of
new RedisClientyou should useredis.createClientcreateClient()takes in an options object as a parameter, you should set the URL there. For more info look at the type definition found underclient.d.ts.->RedisClientOptionsStill broken, have been stuck on this for 8 hours now. I thought that docker’s bridge is assigning wrong aliases, but the issue was here 😞
This works for me :
Still not working
Working solution for typescript: