2 years ago
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
38 Replies
2 years ago
13314144-b328-475d-867f-a0337164519f
2 years ago
I have set the family as you can see
2 years ago
i also have sleep 3 in my start command
2 years ago
nixpacks or dockerfile?
2 years ago
nixpacks with the sleep command in the package.json start command
2 years ago
according to the redis service settings, is that host correct?
2 years ago
redis-cache-staging.railway.internal
Should i have the http infront ?
2 years ago
redis does not use http
2 years ago
kkk let me check. should i justhave
redis-cache-staging.railway.internal
2 years ago
is the redis database in the same environment as the service thats trying to connect to it
2 years ago
yes
2 years ago
are you sure the sleep 3 is being ran?
2 years ago
yes
2 years ago
how so?
2 years ago
2 years ago
i have removed http:// and redeploying now to check
2 years ago
[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379
at _nodeinternal_captureLargerStackTrace (node:internal/errors:496:5)
at _nodeinternal_exceptionWithHostPort (node:internal/errors:671:12)
at TCPConnectWrap.afterConnect as oncomplete
2 years ago
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);
},
};2 years ago
Host is set correctly in the variables
2 years ago
you are still using shared variables
2 years ago
please see this for ioredis
2 years ago
2 years ago
i have applied everything from the railway docs
2 years ago
please stop using shared variables for this
2 years ago
use reference variables
2 years ago
ok changed from shared variables, using reference vars from redis service
2 years ago
Redis port has gone blank on the redis service
2 years ago
use the private url variable please
2 years ago
just like the example in the docs shows
2 years ago
Ok using the private url string only works. But i wonder why you cannot construct using the options with all the same details
2 years ago
probably just configured it wrong
2 years ago
@Brody thanks for all the help man. appreciate it
2 years ago
no problem
2 years ago
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.
"just like the example in the docs shows" does anyone have links to these docs please?
2 years ago
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-redis
Use environment variables -
REDIS_URL=${{Redis.REDIS_PRIVATE_URL}}Append
?family=0to the end of the URL.
Example -
const redis = new Redis(process.env.REDIS_URL + "?family=0");a year ago
Hi, I'm still having this exact issue.
I'm running:
ioredis 5.5.0
node 22.8.0
I'm configuring the redis instance like this:
```
const redisClient = new Redis(`${process.env.REDIS_URL}?family=0`, {
tls: { rejectUnauthorized: false },
lazyConnect: true,
connectTimeout: 15000,
retryStrategy: (times) => Math.min(times * 30, 1000),
});```
My redis url looks like this when I print it out: redis://default:yyBqSILlgwiYDnZOPgvQELaUAmvKLjgc@redis.railway.internal:6379
I'm using setting the REDIS_URL variable like this on railway: ${{Redis.REDIS_URL}}
Also regarding @brody's checklist, "ensure V2 runtime enabled" - I cannot see such on option on either my redis-service or my backend-service config. Is there another way to configure this?
One thing to note is that my redis service is deployed in a US region while the backend is in europe. Ofc I'd want them both in Europe but its currently not an option on the hobby plan.
Thanks in advance!
michael88
Hi, I'm still having this exact issue.I'm running:ioredis 5.5.0node 22.8.0I'm configuring the redis instance like this:```const redisClient = new Redis(`${process.env.REDIS_URL}?family=0`, { tls: { rejectUnauthorized: false }, lazyConnect: true, connectTimeout: 15000, retryStrategy: (times) => Math.min(times * 30, 1000), });```My redis url looks like this when I print it out: redis://default:yyBqSILlgwiYDnZOPgvQELaUAmvKLjgc@redis.railway.internal:6379I'm using setting the REDIS_URL variable like this on railway: ${{Redis.REDIS_URL}}Also regarding @brody's checklist, "ensure V2 runtime enabled" - I cannot see such on option on either my redis-service or my backend-service config. Is there another way to configure this?One thing to note is that my redis service is deployed in a US region while the backend is in europe. Ofc I'd want them both in Europe but its currently not an option on the hobby plan.Thanks in advance!
a year ago
Can you please open your own help thread, a new thread would be preferable over an 8 month old thread.
a year ago
!s