2 years ago
how do i create a redis db in railway and use it for caching
92 Replies
REDIS_URL="redis://default:${{REDIS_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:6379"
2 years ago
In your project, you can right click, click on Database, and click on Add Redis
From there you can connect to redis using the REDIS_URL variable which you can find in the Variables tab (you can set up a shared variable to directly link it into your service's variables)
REDIS_URL="redis://default:${{REDIS_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:6379"
REDISHOST="${{RAILWAY_PRIVATE_DOMAIN}}"
REDISPASSWORD="${{REDIS_PASSWORD}}"
REDISPORT="6379"
REDISUSER="default"2 years ago
check the REDIS_PASSWORD variable for the password and service settings for private domain
or click on the eye icon to see what the final value is
2 years ago
that's the public domain, the private domain would be a railway.internal domain
2 years ago
it's much easier just clicking on the eye icon next to the variable to see the actual value though
2 years ago
yes
2 years ago
correct
2 years ago
that looks about right (assuming pass is your password)
2 years ago
It's recommended you use reference variables instead of defining the variable manually (although doing it manually will still work)
2 years ago
REDIS_STRING="${{Redis.REDIS_URL}}"2 years ago
You get 0.5GB on trial, 5GB on hobby and up to like 250GB or something on pro
2 years ago
yup
2 years ago
yes, your bot will run 24/7 on Railway
2 years ago
true!!
2 years ago
well, idk if there's a limit on projects, projects are just a container for services so the real question is how many services
2 years ago
there isn't a service limit on hobby or pro (at least that I know of)
2 years ago
there is one on trial, I'm not exactly sure how many that is
2 years ago
yea, your app is deployed into a docker container
i was trying to add a postgresql database for my discord bot in railway
2 years ago
how many services do you currently have?
2 years ago
Here's a rundown of Railway's terminology

2 years ago
yeaa 😬 it's likely you hit that service limit I mentioned earlier
2 years ago
My recommendation would be to host databases outside of Railway, MongoDB could go on MongoDB atlas for example
I used to do that and it worked very well, great for saving on costs too
2 years ago
that, or just upgrade to hobby plan, if you're a hobbyist developer then you probably won't regret it
2 years ago
yea that's a whole can of worms, hosting your databases yourself could work perfectly for sure
although it's probably easier just finding free database hosting solutions online (e.g, atlas for mongodb)
2 years ago
then your actual code can stay on Railway
2 years ago
yea, though exposing it is definitely possible but outside the scope of this help thread
2 years ago
my suggestion: find free database hosting solutions online and host your code on Railway
2 years ago
oh fair
You can create a template and add as many services as you'd like. All you need to do is give us a service name and a link to the GitHub URL where the code for the service is located. You can still configure service-level environment variables along with default values and descriptions for each variable.
2 years ago
what's that in reference to?
2 years ago
why do you want to make a template?
Error: SequelizeConnectionError: password authentication failed for user "arrow" postgresql error in railway
2 years ago
sorry I was eating a hotdog
2 years ago
yes, you can go to the Deployments tab, click on the hamburger menu thingy and you'll see an option to remove the running deployment
2 years ago
going to bed will check back when I wake up
2 years ago
I'm back, was there anything else you needed help with or am I free to mark as solved?
2 years ago
Use a proper database client like dbgate
2 years ago
Google it! better you read the docs than trust everything we say
2 years ago
Again, google it.
2 years ago
Both Railway and dbgate have docs you can read
2 years ago
@glitchdetected1 can I finally mark this as solved <:PinkPlead:1033655200659026020>
2 years ago
<:whyy2:820544722572673045>
2 years ago
I can't wait that long, marking as solved, feel free to open another one if you need more help
2 years ago
!s
Status changed to Solved dev • over 1 year ago