Correct environment variables

environment variables DATABASE_URL REDIS_URL Is this correct or should I specify the value from the database and redis ?
No description
85 Replies
Percy
Percy8mo ago
Project ID: 8b1e4ae6-f221-4948-a158-23868f94c7db
testerOne
testerOne8mo ago
8b1e4ae6-f221-4948-a158-23868f94c7db
Fragly
Fragly8mo ago
that looks correct to me, although one thing to keep in mind is that you're using the public url of the databases which will result in egress usage, you'd typically want to use the private_url when possible but this should work nonetheless
testerOne
testerOne8mo ago
I understand well, it can show that this is a link to the created database. Please tell me, I can’t change the region in any way? I need to be in Asia because I’m from Kazakhstan. I'm not going to change it after that.
No description
Fragly
Fragly8mo ago
yea, unfortunately regions is a feature limited to Pro Plan at the moment
testerOne
testerOne8mo ago
OK ! I hope this doesn't affect the speed too much. In any case, I'll test it for now. Perhaps in September I will be able to develop an application-website forum and then I will choose a plan and choose Asia for myself)
Fragly
Fragly8mo ago
Sounds good, best of luck
testerOne
testerOne8mo ago
Last stupid question 😄 How can I navigate the path now? Previously, when I was on localhost, I wrote localhost:7001 .. now I don’t see a path that I can take
Fragly
Fragly8mo ago
if you want to expose your service to the internet then you can go to your service settings and generate a domain for it ( or add a custom domain ) once you've done that then your app should be live on that domain although one thing to note is that your app should be listening on the port that Railway provides which can be found in an environment variable called PORT in nodejs you can get the port by doing something like this:
const port = process.env.PORT || 3000
const port = process.env.PORT || 3000
testerOne
testerOne8mo ago
ok, I think I did everything according to the guide, but so far I don’t see anything on the link
No description
Fragly
Fragly8mo ago
mind sharing your link?
testerOne
testerOne8mo ago
oh everything worked! you just had to wait! THANK YOU VERY MUCH ! I'M SO HAPPY ! I WISH YOU ALL THE KINDEST AND BEST THIS DAY AND THIS YEAR! THIS IS JUST GORGEOUS! THANK YOU ! Now works https://stroyberymedusabackend-production.up.railway.app/app/login
Fragly
Fragly8mo ago
oh, awesome!
testerOne
testerOne8mo ago
Can I ask for more? Am I doing everything right? More likely, what am I doing wrong? I want to install a new user for the admin panel
No description
No description
testerOne
testerOne8mo ago
i use - railway login -railway link
Fragly
Fragly8mo ago
for the first one, you're supposed to run railway link, this will lead you through a few steps where you can select which project to use the second one, idk, i've never used the medusa CLI before ( i didn't even know that existed )
testerOne
testerOne8mo ago
That correct ?
No description
Fragly
Fragly8mo ago
seems like you're on the right path oh hold on though, what do you mean by this? " I want to install a new user for the admin panel"
testerOne
testerOne8mo ago
Now if I write ~railway shell~, will I be inside cmd railway?
Fragly
Fragly8mo ago
Railway doesn't allow for SSH access unfortunately there's no way to directly interact with your container
testerOne
testerOne8mo ago
In Medusa you need to write the command npx medusa user --email [email protected] --password supersecret in cmd so you can log into the admin panel I can’t figure out how to connect to the cmd of my project to write this command
Fragly
Fragly8mo ago
even if you could, it wouldn't be much help, your app doesn't run in a traditional VM on Railway but rather an ephimeral container so anything you do in that container is going to be wiped when you redeploy your project
Fragly
Fragly8mo ago
ooh i see, sorry I'm unfamiliar with medusa, let me skim through the docs real quick it creates a new user on the database, that makes sense
I can’t figure out how to connect to the cmd of my project to write this command
On railway there isn't really anyway to run commands in the container of your project railway run runs a command locally but with the same env as your railway project
testerOne
testerOne8mo ago
I don't understand, did I miss something? It's like it goes into the railroad, but then it does it locally on my PC..
No description
Fragly
Fragly8mo ago
yea, like I said here, railway run runs a command locally but with the same environment variables as your railway project
testerOne
testerOne8mo ago
How can I transfer user data to log in? https://discord.com/channels/713503345364697088/1097967314655268925/1098005657258578070 There was a similar task here, but he somehow managed it, as I understand it
Fragly
Fragly8mo ago
yea right now I'm trying to figure out why you're getting this error
No description
Fragly
Fragly8mo ago
do you have a database connected to your medusa service?
testerOne
testerOne8mo ago
i think so
No description
testerOne
testerOne8mo ago
No description
Fragly
Fragly8mo ago
dang yea I'm completely out of ideas, I did find https://github.com/medusajs/medusa/issues/4449 although the solutions there seems like workarounds instead of actual solutions, although maybe some of the workarounds will work for you I have no idea why you're getitng that error, it's an issue with Medua CLI though
testerOne
testerOne7mo ago
Thank u 3 @Fragly hi Can i asq u again pls?
Fragly
Fragly7mo ago
about this same error?
testerOne
testerOne7mo ago
Maybe. Please tell me this column, is it related to the fact that I connected the database incorrectly? This is the value for 2 or 3 days Seems strangely big
No description
testerOne
testerOne7mo ago
No description
Fragly
Fragly7mo ago
Definitally seems like it yes, do you need help correctly setting it up?
testerOne
testerOne7mo ago
40 gb 2 day.. yes please
Fragly
Fragly7mo ago
Alright, mind opening your own thread? ooh wait this is your thread 🤣
testerOne
testerOne7mo ago
:salute:
Fragly
Fragly7mo ago
In the service you're connecting Postgres to, in this case "stroyberyMedusa..." could you go verify that your database variables still look like this?
No description
testerOne
testerOne7mo ago
DATABASE_TYPE=postgres PGHOST=${{Postgres.PGHOST}} PGPASSWORD=${{Postgres.PGPASSWORD}} PGPORT=${{Postgres.PGPORT}} PGUSER=${{Postgres.PGUSER}} PORT=9000 REDISHOST=${{Redis.REDISHOST}} REDISPASSWORD=${{Redis.REDISPASSWORD}} REDISPORT=${{Redis.REDISPORT}} REDISUSER=${{Redis.REDISUSER}} REDIS_URL=${{Redis.REDIS_URL}} CACHE_REDIS_URL=${{Redis.REDIS_URL}} STORE_CORS=/vercel.app$/ ADMIN_CORS=/vercel.app$/ MEDUSA_BACKEND_URL=https://stroyberymedusabackend-production.up.railway.app DATABASE_URL=${{Postgres.DATABASE_URL}}
Fragly
Fragly7mo ago
oh, cool, that works too
testerOne
testerOne7mo ago
I'm not sure I need that much
Fragly
Fragly7mo ago
DATABASE_TYPE=postgres
PGHOST=${{Postgres.PGHOST}}
PGPASSWORD=${{Postgres.PGPASSWORD}}
PGPORT=${{Postgres.PGPORT}}
PGUSER=${{Postgres.PGUSER}}
PORT=9000
REDISHOST=${{Redis.REDISHOST}}
REDISPASSWORD=${{Redis.REDISPASSWORD}}
REDISPORT=${{Redis.REDISPORT}}
REDISUSER=${{Redis.REDIS_PRIVATE_URL}}
REDIS_URL=${{Redis.REDIS_PRIVATE_URL}}
CACHE_REDIS_URL=${{Redis.REDIS_PRIVATE_URL}}
STORE_CORS=/vercel.app$/
ADMIN_CORS=/vercel.app$/
MEDUSA_BACKEND_URL=https://stroyberymedusabackend-production.up.railway.app/
DATABASE_URL=${{Postgres.DATABASE_PRIVATE_URL}}
DATABASE_TYPE=postgres
PGHOST=${{Postgres.PGHOST}}
PGPASSWORD=${{Postgres.PGPASSWORD}}
PGPORT=${{Postgres.PGPORT}}
PGUSER=${{Postgres.PGUSER}}
PORT=9000
REDISHOST=${{Redis.REDISHOST}}
REDISPASSWORD=${{Redis.REDISPASSWORD}}
REDISPORT=${{Redis.REDISPORT}}
REDISUSER=${{Redis.REDIS_PRIVATE_URL}}
REDIS_URL=${{Redis.REDIS_PRIVATE_URL}}
CACHE_REDIS_URL=${{Redis.REDIS_PRIVATE_URL}}
STORE_CORS=/vercel.app$/
ADMIN_CORS=/vercel.app$/
MEDUSA_BACKEND_URL=https://stroyberymedusabackend-production.up.railway.app/
DATABASE_URL=${{Postgres.DATABASE_PRIVATE_URL}}
I changed your public database URLs to private URLs My only concern is that you also seem to specify parts of the connection string as well (PGHOST, PGPORT, REDISHOST, etc..) The problem is that railway doesn't show the service variables for private urls connection parts by default if you're using those individual parts to build a connection somewhere in your script then it's possible you'll still be connected over the public network there is of course a way to show the private connection string parts in a database but that would involve using a different service for the database which may take some more work to set up, and I'm personally unsure of how to transfer data between such services (I'm not all that knowledgeable about databases) Do you know if you're using those individual connection parts to connect to the database or do you use the entire connection string (DATABASE_URL and REDIS_URL), if you're only using the entire connection string then the above configuration should work fine
testerOne
testerOne7mo ago
The documentation only lists these variables, I think I'll delete everything else
No description
Fragly
Fragly7mo ago
oh fantastic! then the above configuration should work fine
testerOne
testerOne7mo ago
i can use just that ?
No description
Fragly
Fragly7mo ago
nope, replace:
DATABASE_URL=${{Postgres.DATABASE_URL}}
REDIS_URL=${{Redis.REDIS_URL}}
DATABASE_URL=${{Postgres.DATABASE_URL}}
REDIS_URL=${{Redis.REDIS_URL}}
with
DATABASE_URL=${{Postgres.DATABASE_PRIVATE_URL}}
REDIS_URL=${{Redis.REDIS_PRIVATE_URL}}
DATABASE_URL=${{Postgres.DATABASE_PRIVATE_URL}}
REDIS_URL=${{Redis.REDIS_PRIVATE_URL}}
testerOne
testerOne7mo ago
Ok Is this the reason why I had 40 GB?@Fragly
testerOne
testerOne7mo ago
Should I still have settings here? It's a pity that you don't have remote access.
No description
No description
Fragly
Fragly7mo ago
yes don't change anything in the database services very likely
testerOne
testerOne7mo ago
I also have a long delay when I request data from the server I can tunnel through the cli, or do a trace, ping, to understand whether this is a problem in my code or in the remoteness of the server?
No description
Fragly
Fragly7mo ago
I can tunnel through the cli
Railway doesn't support SSH or anything like that if that's what you're asking trace route or ping could probably help you debug though I'm in South Africa with a website hosted in US-West on Railway and I have about 400ms response time so unless you're further away from US-West than I am it's likely an issue with your code
testerOne
testerOne7mo ago
I am in Kazakhstan. Thank you very much ! I'm going home from work. I set a hard limit of $10 just in case to avoid getting a heart attack in the morning 😄 I will try to work on the site
Fragly
Fragly7mo ago
Sounds good, hope this new configuration works out 🙂
Brody
Brody7mo ago
after reading this thread, I think it would be best if you could show us all your raw variables (the ones that aren't sensitive) for your medusa backend, I'm not quite sure you have followed fragly's instructions perfectly
testerOne
testerOne7mo ago
When I have (private) I get this error DATABASE_TYPE=postgres PGHOST=${{Postgres.PGHOST}} PGPASSWORD=${{Postgres.PGPASSWORD}} PGPORT=${{Postgres.PGPORT}} PGUSER=${{Postgres.PGUSER}} PORT=9000 REDISHOST=${{Redis.REDISHOST}} REDISPASSWORD=${{Redis.REDISPASSWORD}} REDISPORT=${{Redis.REDISPORT}} REDISUSER=${{Redis.REDISUSER}} REDIS_URL=${{Redis.REDIS_URL}} CACHE_REDIS_URL=${{Redis.REDIS_URL}} STORE_CORS=/vercel.app$/ ADMIN_CORS=/vercel.app$/ MEDUSA_BACKEND_URL=https://stroyberymedusabackend-production.up.railway.app/ DATABASE_URL=${{Postgres.DATABASE_URL}}
No description
Brody
Brody7mo ago
you didn't do anything fragly has said, please review his messages
testerOne
testerOne7mo ago
DATABASE_URL=${{Postgres.DATABASE_PRIVATE_URL}} REDIS_URL=${{Redis.REDIS_PRIVATE_URL}} Here yea ? When I put this I get an error, screenshot of which is aboveI think I can remove all other variables, but I can’t put (private) Because I get an error Both at the back and at the front
No description
No description
No description
Brody
Brody7mo ago
you need to check the deployment logs
testerOne
testerOne7mo ago
} [ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis.railway.internal at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:108:26) [ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis.railway.internal at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:108:26) [ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis.railway.internal at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:108:26) Error: getaddrinfo ENOTFOUND redis.railway.internal at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:108:26) { errno: -3007, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'redis.railway.internal' }
Brody
Brody7mo ago
update the redis variable to -
REDIS_URL=${{Redis.REDIS_PRIVATE_URL}}?family=6
REDIS_URL=${{Redis.REDIS_PRIVATE_URL}}?family=6
testerOne
testerOne7mo ago
I'll try it now thanks
No description
testerOne
testerOne7mo ago
Holy! it works ! Thank you very much
Brody
Brody7mo ago
no problem
testerOne
testerOne6mo ago
I didn't change anything but my images disappeared.
No description
testerOne
testerOne6mo ago
@BrodyCould this be due to the settings we used?
Brody
Brody6mo ago
no, but what kind of app is this again?
testerOne
testerOne6mo ago
Get started with Next.js for e-commerce | Medusa
Learn how to get started with a Next.js storefront and Medusa. The Next.js Starter includes ready-integrations with plugins like Stripe and Algolia. It offers features like customer accounts, cart and checkout flows, and more.
Brody
Brody6mo ago
do you have a volume mounted to it?
testerOne
testerOne6mo ago
What do you have in mind?
Brody
Brody6mo ago
haha that was a yes or no question
testerOne
testerOne6mo ago
I don't know
Brody
Brody6mo ago
please check
testerOne
testerOne6mo ago
volume mounted?
Brody
Brody6mo ago
yep thats what i asked, do you have one mounted to the medusa backend?
testerOne
testerOne6mo ago
More likely no than yes. This is the first time I've ever heard of this
Brody
Brody6mo ago
please check
testerOne
testerOne6mo ago
In any case, I don't even know how to do it
Brody
Brody6mo ago
look at the service on the project canvas, does it have a volume?
testerOne
testerOne6mo ago
here?
No description
testerOne
testerOne6mo ago
I don't understand what canvas you're talking about
Want results from more Discord servers?
Add your server