23 days ago
I am attempting to have 3 new services I added to my project link to my API. I used the same method I used to link my API to the Redis and Postgres but they are not linking. I am not sure what I am doing wrong. The way I was able to get Redis and Postgres to connect was using their internal networking as env vars for each other, and when I redeployed it linked and was good. I did the same for the 3 on the left and they redeployed but are not communicating and not allowing the pages on the left to communicate with the api or the redis and postgres.
Attachments
Pinned Solution
22 days ago
Yes you should definitely link them internally to the API, as the public connection incurs egress charges. Meaning you will pay extra money for no reason.
Connecting to the API internally ensures your services communicate with the API without any egress usage.
Avoid public connections whenever possible.
11 Replies
23 days 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 Railway • 23 days ago
23 days ago
You will need to use the reference variables. Eg, for Postgres database URL, you would use something like ${{Postgres.DATABASE_URL}}
https://docs.railway.com/guides/variables#reference-variables
22 days ago
So would I then just use ${{dev-portal.DATABASE_URL}} and repeat for each service?
22 days ago
If you want to link the newly added 3 services to your redis and postgres, you would have to add ${{ Postgres.DATABASE_URL }} and ${{ Redis.REDIS_URL }} in each one of your 3 services as environment variables.
dev-portal service example:
DATABASE_URL=${{Postgres.DATABASE_URL}}
REDIS_URL=${{ Redis.REDIS_URL }}
Alternatively, you can use Shared Variables in you project settings, to set those variables in one place and share them across your services.
darseen
If you want to link the newly added 3 services to your redis and postgres, you would have to add ${{ Postgres.DATABASE_URL }} and ${{ Redis.REDIS_URL }} in each one of your 3 services as environment variables. dev-portal service example:DATABASE_URL=${{Postgres.DATABASE_URL}}REDIS_URL=${{ Redis.REDIS_URL }}Alternatively, you can use Shared Variables in you project settings, to set those variables in one place and share them across your services.
22 days ago
I am trying to link the 3 new servicecs to API, basically my API is going to be the middleman between the 3 new services and the postgres and redis. The 3 new services are the website that need to communicate with the API and then the API will communicate with the redis and postgres. Does that make sense or am I building this all wrong?
cannamuffinman
I am trying to link the 3 new servicecs to API, basically my API is going to be the middleman between the 3 new services and the postgres and redis. The 3 new services are the website that need to communicate with the API and then the API will communicate with the redis and postgres. Does that make sense or am I building this all wrong?
22 days ago
Yeah, it totally makes sense to do it this way. Your backend API should communicate with your postgres/redis on behalf of your client services. But in this case, you wouldn't set environment variables for postgres/redis in those 3 services. You only need to link the 3services to the backend API.
22 days ago
Exactly what I thought! Cause they make API calls but some of their calls create data for the postgres so i didn't see the need to have the frontend bypassing the API. I'm self teaching and a novice(like this is my first project of this caliber), and I have never worked with programming outside a mono-repo/executables so trying to understand how to really do this. As it stands, I do have the internal api var in the 3 new services and the 3 new services internal var set to the api exactly as it says so where you get the var from. So I am confused as to why it didn't link after redeploy.
cannamuffinman
Exactly what I thought! Cause they make API calls but some of their calls create data for the postgres so i didn't see the need to have the frontend bypassing the API. I'm self teaching and a novice(like this is my first project of this caliber), and I have never worked with programming outside a mono-repo/executables so trying to understand how to really do this. As it stands, I do have the internal api var in the 3 new services and the 3 new services internal var set to the api exactly as it says so where you get the var from. So I am confused as to why it didn't link after redeploy.
22 days ago
If they are still not linked, you need to provide more info to determine the cause. Such as: error logs and your variables setup in the dashboard (without exposing any secret ones).
darseen
If they are still not linked, you need to provide more info to determine the cause. Such as: error logs and your variables setup in the dashboard (without exposing any secret ones).
22 days ago
So I may not need them to communicate internally since I do have them pointing to the public api endpoints(written directly into my code) and didn't consider the communication errors I was having were coding issues not related to the 3 new services not being directly linked internally. Would linking them internally make a difference?
cannamuffinman
So I may not need them to communicate internally since I do have them pointing to the public api endpoints(written directly into my code) and didn't consider the communication errors I was having were coding issues not related to the 3 new services not being directly linked internally. Would linking them internally make a difference?
22 days ago
Yes you should definitely link them internally to the API, as the public connection incurs egress charges. Meaning you will pay extra money for no reason.
Connecting to the API internally ensures your services communicate with the API without any egress usage.
Avoid public connections whenever possible.
darseen
Yes you should definitely link them internally to the API, as the public connection incurs egress charges. Meaning you will pay extra money for no reason.Connecting to the API internally ensures your services communicate with the API without any egress usage.Avoid public connections whenever possible.
22 days ago
OH, that is super good to know. I'll have to look see what i can run internally cause I dont think any of my code currently can serve to the user and communicate internally. I am building a content aggregator but with a uniquely insane new concept, I wrote the blockchain technology directly into the source code and changed the mining and minting process to be less detrimental to the environment and will no longer have any impact on the chip market. It still maintains the complexity of blockchain technology but simplifies the mining process(to what it was always capable of doing). I really hope this does well, I maybe have 2-3 more weeks of solo-dev work to get done before I can fully launch(plus the legal stuff)
cannamuffinman
OH, that is super good to know. I'll have to look see what i can run internally cause I dont think any of my code currently can serve to the user and communicate internally. I am building a content aggregator but with a uniquely insane new concept, I wrote the blockchain technology directly into the source code and changed the mining and minting process to be less detrimental to the environment and will no longer have any impact on the chip market. It still maintains the complexity of blockchain technology but simplifies the mining process(to what it was always capable of doing). I really hope this does well, I maybe have 2-3 more weeks of solo-dev work to get done before I can fully launch(plus the legal stuff)
22 days ago
But I dont launch that side of the aggregator until i finish my blockchain and smart contract and hammer out the tokenomics final version(tweaking as I do more research on platform hopping) granted I need the data to realllly hammer out how the tokenomics will ultimately operate, but the plan for dencentralization will be creating an executable that users can download to help build a decentralized "network" that'll support the system.
Status changed to Solved brody • 22 days ago
