-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createClient trying to connect with localhost even though URL is for docker's redis instance #2416
Comments
Make sure to pass the url like this: createClient({ url: '...' }); |
I have the same error when I try to connect from AWS lambda using discrete parameters, like host, port, and DB. When I use the URL, it works. |
Yeah, doing that exactly |
@anatoly314 make sure to use this format for discrete parameters: createClient({
socket: {
host: '127.0.0.1',
port: 6379
},
database: 123,
}); see this file for more information. @sk1122 I just ran this code locally import { createClient } from 'redis';
const client = createClient({
url: 'redis://127.0.0.2:6378',
});
client.on('error', err => console.error(err));
await client.connect(); and here is the error I get:
can you please try running the same code and share the error you get? |
I solved this using |
@sk1122 I won't be able to fix it without reproducing the error first... If you can run the script above and share the error you get it'll be very helpful :) |
I think that the issue is that the client is not defaulting to the |
We are running into a similar issue here, using url or discrete options causes this to appear just after
class QueueWorker {
constructor() {
const url = process.env.REDIS_URL ?? "redis://127.0.0.1:6379";
const parsedUrl = new URL(url);
const options = {
socket: {
port: Number.parseInt(parsedUrl.port, 10),
host: parsedUrl.hostname,
family: 4
},
username: parsedUrl.username,
password: parsedUrl.password
};
console.log(options);
this.redisClient = redis.createClient(options);
this.pubSubClient = redis.createClient(options);
this.redisClient.on("error", console.log);
this.pubSubClient.on("error", console.log);
}
async start() {
await this.redisClient.connect();
await this.pubSubClient.connect();
}
}
const worker = new QueueWorker();
await worker.start(); |
In the same set-up I had to swap |
I am experiencing similar issues when using
|
Same here. No matter what I would try, I run into the same issue but only when I set the redis store for session management. The client is at the last version. redis.config.js let redisClients = {};
app.js `
` |
has this problem been solved? How ? |
I seems ok as add 'redis://' for url ,like this |
Hi there, someone here has solve the problem? :) |
Problem is still going on
edis Client Error AggregateError |
@sk1122 Hi, I solved problem like this:
|
Same issue! await createClient({
socket: {
host: "name-of-service",
port: 6379,
},
}).connect(); Error: connect ECONNREFUSED 127.0.0.1:6379 |
Description
I am trying to create a client with URL
redis://${process.env.REDIS_HOST}:${process.env.REDIS_PORT}
, and sendingREDIS_HOST=rediss
andREDIS_PORT=6379
, but still it is trying to connect with localhostNode.js Version
v19.6.0
Redis Server Version
7.0.5
Node Redis Version
4.6.4
Platform
Linux
Logs
The text was updated successfully, but these errors were encountered: