R
Railway13mo ago
joao

node redis

any hacks to connect to redis on node? ive slept the 5s but still conn refused
Solution:
after just looking at the docs, you are using the library incorrectly, please read the docs https://www.npmjs.com/package/redis#usage...
Jump to solution
23 Replies
Percy
Percy13mo ago
Project ID: N/A
joao
joaoOP13mo ago
N/A
Brody
Brody13mo ago
please show the error. are you trying to connect to the database via public or private networking? what library are you using? anything else you think may be useful information
joao
joaoOP13mo ago
i'm using the official node-redis client and conecting via private networking rn im just doing sleep 5 && runcommand lol
Brody
Brody13mo ago
please show the error
joao
joaoOP13mo ago
Error: connect ECONNREFUSED ::1:6379
Brody
Brody13mo ago
show the code that initialises the connection please
joao
joaoOP13mo ago
redisClient = await createClient()
.on("error", (err) => console.log("redis client err:", err))
.on("connect", () => {
console.log("redis conn successful");
app.listen(PORT, () =>
console.log(
`server started on port ${PORT}`
)
);
})
.connect({ url: REDIS_URL });
redisClient = await createClient()
.on("error", (err) => console.log("redis client err:", err))
.on("connect", () => {
console.log("redis conn successful");
app.listen(PORT, () =>
console.log(
`server started on port ${PORT}`
)
);
})
.connect({ url: REDIS_URL });
Brody
Brody13mo ago
have you confirmed that REDIS_URL is the correct value
joao
joaoOP13mo ago
yes its an env var which i set in the dashboard imma try via public netwk
Brody
Brody13mo ago
from this error, it looks like it's trying to connect to localhost, and port 6379, Which is the default when you don't supply the correct information to the connect constructor
joao
joaoOP13mo ago
nope not it yeah i know because of the ipv6 loopback addr lol i checked that but the env var is set
Brody
Brody13mo ago
that's not it, you're thinking of something that's doesn't apply here please confirm your code is seeing the proper redis url can you also show me how you have set the REDIS_URL in code
joao
joaoOP13mo ago
yes the app has access to the variable the REDIS_URL is the value from destructuring process.env
Brody
Brody13mo ago
have you printed that variable to confirm it's correct value?
joao
joaoOP13mo ago
yup
Brody
Brody13mo ago
okay i will try to reproduce
Solution
Brody
Brody13mo ago
after just looking at the docs, you are using the library incorrectly, please read the docs https://www.npmjs.com/package/redis#usage
joao
joaoOP13mo ago
what do you mean wrong
Brody
Brody13mo ago
please read the docs
joao
joaoOP13mo ago
youre right yea now it makes sense sorry abt that it was defaulting to localhost because i wasnt passing the url in the right method
Brody
Brody13mo ago
correct
joao
joaoOP13mo ago
thanks! and sorry for such a stupid mistake
Want results from more Discord servers?
Add your server