R
Railway5mo ago
n-march

PGPORT set correctly?

I keep getting this error when trying to deploy my project: "ValueError: invalid literal for int() with base 10: ' ' ". I believe that my PGPORT is not set up correctly in my shared variables, as I have inspected it and it seems to be an empty string. I'm a noob. Anyone has any ideas what I could try? This is a django project, I'm trying to use postgresql (in Railway)
Solution:
variables don't need to be project level shared to be referenced by other services, once you delete that database and all of the shared variables you have created and have deployed a new one, please leave it as is. then on your django service you would reference the PGPORT variable from the Postgres service like so ``` PGPORT={{Postgres.PGPORT}}...
Jump to solution
9 Replies
Percy
Percy5mo ago
Project ID: b3aa5d3d-8985-46d1-8747-571b21b032d6
Fragly
Fragly5mo ago
mind sharing how you set up your reference variable?
n-march
n-march5mo ago
b3aa5d3d-8985-46d1-8747-571b21b032d6 Is set up as a global variable (which was auto created when I created a postgresql service: ${{Postgres.PGHOST}} This is how I set it up in my settings.py file PGPORT = config('PGPORT', default=5432, cast=int)
Fragly
Fragly5mo ago
Strange is it also an empty string in the postgres service variables?
n-march
n-march5mo ago
Yep
No description
Fragly
Fragly5mo ago
Could you try creating a new Postgres service? then delete the new Postgres service's volume Disconnect the volume from the old service and then mount it to the new service on this mount: /var/lib/postgresql/data you'll then have a new postgres service with hopefully fixed variables, which will have your old data as well if you don't care about the old data then you can just delete both the old service and old mount and deploy a new postgres service
n-march
n-march5mo ago
Sure, let me try doing that.
Brody
Brody5mo ago
all those variables are shared project variables indicated by the globe, they definitely shouldn't be. after everything done to the database, it might be best to just scrap it and deploy another one, this time don't export the variables to global shared variables
Solution
Brody
Brody5mo ago
variables don't need to be project level shared to be referenced by other services, once you delete that database and all of the shared variables you have created and have deployed a new one, please leave it as is. then on your django service you would reference the PGPORT variable from the Postgres service like so
PGPORT={{Postgres.PGPORT}}
PGPORT={{Postgres.PGPORT}}
then of course you just read the PGPORT environment variable in code