Ioredis Node connection issue.
My connection object above
[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND http://redis-cache-staging.railway.internal
Solution:Jump to solution
please see this for ioredis https://docs.railway.app/guides/private-networking#known-configuration-requirements-for-ipv6
30 Replies
Project ID:
13314144-b328-475d-867f-a0337164519f
13314144-b328-475d-867f-a0337164519f
I have set the family as you can see
i also have
sleep 3
in my start commandnixpacks or dockerfile?
nixpacks with the sleep command in the package.json start command
according to the redis service settings, is that host correct?
redis-cache-staging.railway.internal
Should i have the http infront ?
redis does not use http
kkk let me check. should i justhave
redis-cache-staging.railway.internal
is the redis database in the same environment as the service thats trying to connect to it
yes
are you sure the sleep 3 is being ran?
yes
how so?
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)
Host is set correctly in the variables
you are still using shared variables
Solution
please see this for ioredis https://docs.railway.app/guides/private-networking#known-configuration-requirements-for-ipv6
i have applied everything from the railway docs
please stop using shared variables for this
use reference variables
ok changed from shared variables, using reference vars from redis service
Redis port has gone blank on the redis service
use the private url variable please
just like the example in the docs shows
Ok using the private url string only works. But i wonder why you cannot construct using the options with all the same details
probably just configured it wrong
@Brody thanks for all the help man. appreciate it
no problem
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.
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