Ioredis Node connection issue.

const redisConnection: RedisOptions = {
host: `http://${process.env.REDIS_HOST}`,
port: Number(process.env.REDIS_PORT),
password: process.env.REDIS_PASS,
username: process.env.REDIS_USER,
family: 0,
retryStrategy: (times) => {
// reconnect after
return Math.min(times * 50, 2000);
},
};
const redisConnection: RedisOptions = {
host: `http://${process.env.REDIS_HOST}`,
port: Number(process.env.REDIS_PORT),
password: process.env.REDIS_PASS,
username: process.env.REDIS_USER,
family: 0,
retryStrategy: (times) => {
// reconnect after
return Math.min(times * 50, 2000);
},
};
My connection object above [ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND http://redis-cache-staging.railway.internal
30 Replies
Percy
Percy9mo ago
Project ID: 13314144-b328-475d-867f-a0337164519f
TurboFarmer9000
TurboFarmer9000OP9mo ago
13314144-b328-475d-867f-a0337164519f I have set the family as you can see i also have sleep 3 in my start command
Brody
Brody9mo ago
nixpacks or dockerfile?
TurboFarmer9000
TurboFarmer9000OP9mo ago
nixpacks with the sleep command in the package.json start command
Brody
Brody9mo ago
according to the redis service settings, is that host correct?
TurboFarmer9000
TurboFarmer9000OP9mo ago
redis-cache-staging.railway.internal Should i have the http infront ?
Brody
Brody9mo ago
redis does not use http
TurboFarmer9000
TurboFarmer9000OP9mo ago
kkk let me check. should i justhave redis-cache-staging.railway.internal
Brody
Brody9mo ago
is the redis database in the same environment as the service thats trying to connect to it
TurboFarmer9000
TurboFarmer9000OP9mo ago
yes
Brody
Brody9mo ago
are you sure the sleep 3 is being ran?
TurboFarmer9000
TurboFarmer9000OP9mo ago
yes
Brody
Brody9mo ago
how so?
TurboFarmer9000
TurboFarmer9000OP9mo ago
No description
TurboFarmer9000
TurboFarmer9000OP9mo ago
i have removed http:// and redeploying now to check [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379 at node_internal_captureLargerStackTrace (node:internal/errors:496:5) at node_internal_exceptionWithHostPort (node:internal/errors:671:12) at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)
const redisConnection: RedisOptions = {
host: process.env.REDIS_HOST,
port: Number(process.env.REDIS_PORT),
password: process.env.REDIS_PASS,
username: process.env.REDIS_USER,
family: 0,
retryStrategy: (times) => {
// reconnect after
return Math.min(times * 50, 2000);
},
};
const redisConnection: RedisOptions = {
host: process.env.REDIS_HOST,
port: Number(process.env.REDIS_PORT),
password: process.env.REDIS_PASS,
username: process.env.REDIS_USER,
family: 0,
retryStrategy: (times) => {
// reconnect after
return Math.min(times * 50, 2000);
},
};
TurboFarmer9000
TurboFarmer9000OP9mo ago
Host is set correctly in the variables
No description
Brody
Brody9mo ago
you are still using shared variables
TurboFarmer9000
TurboFarmer9000OP9mo ago
No description
TurboFarmer9000
TurboFarmer9000OP9mo ago
i have applied everything from the railway docs
Brody
Brody9mo ago
please stop using shared variables for this use reference variables
TurboFarmer9000
TurboFarmer9000OP9mo ago
ok changed from shared variables, using reference vars from redis service
TurboFarmer9000
TurboFarmer9000OP9mo ago
Redis port has gone blank on the redis service
No description
Brody
Brody9mo ago
use the private url variable please just like the example in the docs shows
TurboFarmer9000
TurboFarmer9000OP9mo ago
Ok using the private url string only works. But i wonder why you cannot construct using the options with all the same details
Brody
Brody9mo ago
probably just configured it wrong
TurboFarmer9000
TurboFarmer9000OP9mo ago
@Brody thanks for all the help man. appreciate it
Brody
Brody9mo ago
no problem
Duchess
Duchess5mo ago
New reply sent from Help Station thread:
Hi sorry to bring this back up, but I'm not able to see the messages on discord, and I think many links are missing here.What is the right solution to get a redis instance running within the same project? I'm having issues with the host being undefined.
You're seeing this because this thread has been automatically linked to the Help Station thread.
Duchess
Duchess5mo ago
New reply sent from Help Station thread:
No worries, the links are indeed missing.Getting ioredis setup correctly with private networking checklist -Make sure you have the V2 runtime enabled in your service settings.Use the URL syntax for the ioredis client as shown here - https://github.com/redis/ioredis/blob/main/README.md#connect-to-redisUse environment variables.Append ?family=0 to the end of the URL.Example -const redis = new Redis(process.env.REDIS_URL + "?family=0");
You're seeing this because this thread has been automatically linked to the Help Station thread.
GitHub
ioredis/README.md at main · redis/ioredis
🚀 A robust, performance-focused, and full-featured Redis client for Node.js. - redis/ioredis
Want results from more Discord servers?
Add your server