R
Railway2y ago
Kuha

Can't deploy with Postgres

I had an app deployed on Heroku, tried coming to Railway for better plans, but when I connect the repo to Railway I get
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
and it crashes
14 Replies
Percy
Percy2y ago
Project ID: c17693fa-8f81-4f00-ad4d-8f231f687806
Percy
Percy2y ago
It looks like manually defining DATABASE_URL worked for Desch, so that might be a solution for you. JustJake also suggested that you shouldn't need to manually define DATABASE_URL, so it might be worth checking that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
⚠️ experimental feature
Kuha
KuhaOP2y ago
c17693fa-8f81-4f00-ad4d-8f231f687806 It recognized my env variables automatically and setted them but didn't work either
Brody
Brody2y ago
where is the database hosted
Kuha
KuhaOP2y ago
I thought the docker postgres image would be automatically loaded as it happens on heroku or other sites
Brody
Brody2y ago
unless its a template no, you need to add a database to your project then use the database environment variables to connect to it
Kuha
KuhaOP2y ago
how do I add it? Its a Spring Java + Postgress but I can't find it in templates
Brody
Brody2y ago
click desired project > + new > database > postgresql
Brody
Brody2y ago
then railway creates these variables for you to use in your code https://docs.railway.app/databases/postgresql
Kuha
KuhaOP2y ago
is there no way to modify the DB variables I get? Like, setting my own username and so?
Brody
Brody2y ago
not that i know of, though theres no need to, if the username and passwork gets leaked you can regen them
Kuha
KuhaOP2y ago
Oh, looks like I had misplaced a variable on my app.properties, thanks a bunch!
Brody
Brody2y ago
no problem
Kuha
KuhaOP2y ago
Wait, no, new error after setting all variables: Driver org.postgresql.Driver claims to not accept jdbcUrl This pops up when it tries to connect to the right url provided by railway Finally got it to work! Thanks!
Want results from more Discord servers?
Add your server