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
28 Replies
Percy
Percy4mo ago
Project ID: 13314144-b328-475d-867f-a0337164519f
TurboFarmer9000
TurboFarmer90004mo 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
Brody4mo ago
nixpacks or dockerfile?
TurboFarmer9000
TurboFarmer90004mo ago
nixpacks with the sleep command in the package.json start command
Brody
Brody4mo ago
according to the redis service settings, is that host correct?
TurboFarmer9000
TurboFarmer90004mo ago
redis-cache-staging.railway.internal Should i have the http infront ?
Brody
Brody4mo ago
redis does not use http
TurboFarmer9000
TurboFarmer90004mo ago
kkk let me check. should i justhave redis-cache-staging.railway.internal
Brody
Brody4mo ago
is the redis database in the same environment as the service thats trying to connect to it
TurboFarmer9000
TurboFarmer90004mo ago
yes
Brody
Brody4mo ago
are you sure the sleep 3 is being ran?
TurboFarmer9000
TurboFarmer90004mo ago
yes
Brody
Brody4mo ago
how so?
TurboFarmer9000
TurboFarmer90004mo ago
No description
TurboFarmer9000
TurboFarmer90004mo 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
TurboFarmer90004mo ago
Host is set correctly in the variables
No description
Brody
Brody4mo ago
you are still using shared variables
TurboFarmer9000
TurboFarmer90004mo ago
No description
TurboFarmer9000
TurboFarmer90004mo ago
i have applied everything from the railway docs
Brody
Brody4mo ago
please stop using shared variables for this use reference variables
TurboFarmer9000
TurboFarmer90004mo ago
ok changed from shared variables, using reference vars from redis service
TurboFarmer9000
TurboFarmer90004mo ago
Redis port has gone blank on the redis service
No description
Brody
Brody4mo ago
use the private url variable please just like the example in the docs shows
TurboFarmer9000
TurboFarmer90004mo 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
Brody4mo ago
probably just configured it wrong
TurboFarmer9000
TurboFarmer90004mo ago
@Brody thanks for all the help man. appreciate it
Brody
Brody4mo ago
no problem