R
Railwayβ€’12mo ago
djilousp

Unable to set PostGIS template environment variables correctly

I'm setting all the required env vars :
PGHOST
PGPORT
PGUSER
PGPASSWORD
PGDATABASE
DATABASE_URL
PGHOST
PGPORT
PGUSER
PGPASSWORD
PGDATABASE
DATABASE_URL
but it keeps showing that these vars are required. The second this is that when I try to connect to the database using the env vars I used it says either the password is wrong ( and database doesn't exist in other cases)
No description
22 Replies
Percy
Percyβ€’12mo ago
Project ID: 2fe6b2a5-c072-4ea0-ab34-43e08ee347f9
djilousp
djilouspβ€’12mo ago
2fe6b2a5-c072-4ea0-ab34-43e08ee347f9
Brody
Brodyβ€’12mo ago
is this a database included with a template? if so please link the template
djilousp
djilouspβ€’12mo ago
I created an app service in the project, then I needed a DB with PostGIS installed so I used PostGIS Template, the docker images being is postgis so basically just adding those env variables new default user and db should be created, but not so sure it's happening, besides why does the Data tab keeps showing Required Variables component even if the DB is actually configured with default values? what should happen once they are all set !
Brody
Brodyβ€’12mo ago
can you connect to the database just fine?
djilousp
djilouspβ€’12mo ago
with default values yes, but not when I set new ones
Brody
Brodyβ€’12mo ago
why are you changing variables on the database?
djilousp
djilouspβ€’12mo ago
I need to set my own
POSTGRES_PASSWORD
POSTGRES_USER
POSTGRES_DB
POSTGRES_PASSWORD
POSTGRES_USER
POSTGRES_DB
values
Brody
Brodyβ€’12mo ago
whats wrong with the values the database comes with?
djilousp
djilouspβ€’12mo ago
well my db won't be called railway neither my db user, and I suppose they should be configurable aren't they ? postgis is based on postgres images which allows to set those env variables (thing you did in PostGIS template) the question is : are those env variables overwritten in the PostGIS Template when configured !
Brody
Brodyβ€’12mo ago
theyre set on first deploy, changing them after the fact will only cause issues, but i really cant see why you need to change them reference the variables in your service and use the values as is https://docs.railway.app/develop/variables#reference-variables
djilousp
djilouspβ€’12mo ago
so I should keep the same DB and user names in my app right !!!! well i'm sorry but it doesn't make too much sense first thing is that you have made them configurable 2nd you can't force a customer using your own default naming conventions in a configurabale component, it just doesn't make sense !!
Brody
Brodyβ€’12mo ago
please chill, i dont work for railway you should be using environment variables, do not hardcode any database names, usernames, or passwords
djilousp
djilouspβ€’12mo ago
I'm not hard coding anything, I was just trying to changes values for those env variables and use them to connect to Db from my app service, it's as simple as that who does than πŸ˜… ! I just want to make sure resetting those env variables in a PostGIS Template works as intended !
Brody
Brodyβ€’12mo ago
as a hobby user you get community support! pro plan users and above get support from the team but besides that, that is simply how that docker image works, and like i said, the values they come with should not matter as long as your code uses environment variables properly im just trying to help you come to the proper solution
djilousp
djilouspβ€’12mo ago
I appreciate the help man, but still not sure if you got what I was trying to do, I never used hard coded values, I just changed the default values PostGIS template comes with, and by doing that in the next deployment, a new default DB and User (from the new values) should be created then using those same values also as env vars from my app service
Brody
Brodyβ€’12mo ago
i get what youre trying to do, but i dont understand why, did you leak the database credentials? either way, if the image isnt setting the new variables that kinda out of railway's hands, railway does not maintain that image
djilousp
djilouspβ€’12mo ago
voila thank you btw I pulled the postgis image from docker hub locally, set those env vars and I was able to connect to the db using the values I used πŸ˜… I wanted to know whether there is something wrong with Railway Api or not
Brody
Brodyβ€’12mo ago
unless you leaked the password, i just dont see why you need to change them
djilousp
djilouspβ€’12mo ago
the password is not really leaked, but I just don't want the whole world to know my db name and user πŸ˜… and I think this why postgres image made those env vars configurable
Brody
Brodyβ€’12mo ago
ive been here a long time, you are the first to worry about this
djilousp
djilouspβ€’12mo ago
maybe because I've played a lot of CTFs xD anyway thanks a lot for your help @Brody
Want results from more Discord servers?
Add your server