5 months ago
Hello!
I need help, when developing, i use the public URLs in my en variables, whether for Regis or the Postgres database, but after deployment, i make sure to change them to the normal internal url. Still, for some reason, it fails to connect. In development, I'm using the DB and everything without problem with the public URLs. Still, in prod, every connection, including redis, are just failing endlessly, causing my api to become inaccessible. i need help understanding what is going on. Please!
9 Replies
5 months ago
Hey there! We've found the following might help you get unblocked faster:
🧵 Railway Support Request - Internal Database Connection Failure
🧵 Outbound WebSocket Connection to Deepgram API Fails Silently
If you find the answer from one of these, please let us know by solving the thread!
5 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 5 months ago
5 months ago
Make sure all of the environment variables in your code are named exactly as variables in your project. For example when you call REDIS_URL in your code, REDIS_URL must exist in your projects envirnoment.
You can add variable reference to your container. If you want to have variables in sync there is better chance you will not have issues. When using raw editor, you can add:
REDIS_URL="${{TITLE_OF_YOUR_SERVICE.REDIS_URL}}". You can also add variable reference with purple prompt before the list of variables. You can implement the same solution for your database internal(private) url.Make sure you do NOT upload your .env file to github, as it may create confusion with which variable value to take (not tested, just an instinct)
Make sure your private URLs are in valid format and that they are not somehow modified.
For example in my Rust code when I need database private url:let database_url = dotenvy::var("DATABASE_URL_PRIVATE").expect("DATABASE_URL_PRIVATE must be set");
DATABASE_URL_PRIVATE exists in .env file AND in variable list of your project. DATABASE_URL_PRIVATE is a variable reference to my MySQL container variable which contains URL.
I hope I was of some help.
5 months ago
I see, i understand but unfortunately, that is not my problem because the moment i changed the urls to public urls, they start working flawlessly even in production environement, but the moment go back to internal url i see this, and to be precise the issue is mainly with redis. As you can see bellow is the errors, the same thing just repeating for all my redis instances. As for the implementation, here is a snipet of my connection:
import Redis from "ioredis";
import { AUTH_REDIS_URL } from "./env.js";
const redis = new Redis(AUTH_REDIS_URL);
redis.on("connect", () => {
console.log("Auth Redis connected");
});
redis.on("error", (err) => {
console.log("Error connecting to auth redis", err);
});
export default redis;
DNSException: getaddrinfo ENOTFOUND
syscall: "getaddrinfo",
errno: 4,
code: "ENOTFOUND"
DNSException: getaddrinfo ENOTFOUND
syscall: "getaddrinfo",
errno: 4,
code: "ENOTFOUND"
DNSException: getaddrinfo ENOTFOUND
Redis connection closed
Reconnecting to Redis...
Error connecting to CHAT REDIS DNSException: getaddrinfo ENOTFOUND
syscall: "getaddrinfo",
errno: 4,
code: "ENOTFOUND"
Reconecting to Chat Redis
Error connecting to searchRecommendation redis DNSException: getaddrinfo ENOTFOUND
syscall: "getaddrinfo",
errno: 4,
code: "ENOTFOUND"
Error connecting to auth redis DNSException: getaddrinfo ENOTFOUND
syscall: "getaddrinfo",
errno: 4,
code: "ENOTFOUND"
5 months ago
I never had such issue with private Redis url.
If you do not have data in current Redis instance, best advice I can give you is to create a new instance from the template and use it. Good luck!
5 months ago
The same issue happen even after creating a new redis instance
5 months ago
I just replaced on the redis instances with a valkey template and it is the exact same error
DNSException: getaddrinfo ENOTFOUND
syscall: "getaddrinfo",
errno: 4,
code: "ENOTFOUND"
Some sort of internal dns error.
5 months ago
Hey john, can you try adding ?family=0 to your REDIS_URL? I believe that your issue is related to https://docs.railway.com/reference/errors/enotfound-redis-railway-internal.
uxuz
Hey john, can you try adding ?family=0 to your REDIS_URL? I believe that your issue is related to https://docs.railway.com/reference/errors/enotfound-redis-railway-internal.
5 months ago
Thanks man. My service is just back online; this was the issue. This thing has already burned $10 as egress fee because of the endless restarting of the container on each failure, Starting Container
Initializing BullMQ workers
The main server is running on port 8000
Connected to Queues Redis successfully
Chat Redis connected
Auth Redis connected
Connected to searchRecommendation redis Thanks a lot
Status changed to Solved uxuz • 5 months ago
