Can't get correct DB connection

liangk
FREEOP

a month ago

In the beginning I can't add a column to User table. I remove Postgres service and add a new one. Now I got a new DATABASE_URL. Something like
postgresql://postgres:password@maglev.proxy.rlwy.net:22488/railway
However the error meesage seems imply old value is used. Like
> prisma migrate deploy

> Prisma schema loaded from prisma/schema.prisma

Datasource "db": PostgreSQL database "railway", schema "public" at "shortline.proxy.rlwy.net:48652"

Error: P1001: Can't reach database server at shortline.proxy.rlwy.net:48652

Please make sure your database server is running at shortline.proxy.rlwy.net:48652.
My Github is at
https://github.com/liangk/fullstack-auth-boilerplate

Solved$10 Bounty

9 Replies

Railway
BOT

a month ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


a month 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 brody about 1 month ago


a month ago

Hey there!
With prisma, DATABASE_URL refers to an env variable.
On your service (the fullstack-auth-boilerplate) did you set DATABASE_URL to the correct value?
That would be heading over to postgres and copying the DATABASE_URL field.
Your other option is using variable references${{Postgres.DATABASE_URL}}.

Attachments


liangk
FREEOP

a month ago

I did. I copy and paste from Postgres. Now I set DATABASE_URL to ${{Postgres.DATABASE_URL}} and test again. I got the same error


a month ago

To verify, are you restarting the fullstack-auth-boilerplateafter setting the new value of DATABASE_URL?


liangk
FREEOP

a month ago

I redeployed. Now trying restart


liangk
FREEOP

a month ago

Well, the same error


a month ago

Well redeploying is the same so all good there!


a month ago

So I looked over the repo you provided, https://github.com/liangk/fullstack-auth-boilerplate, and I see you're using a docker compose file.
This part of the docs mentions that not all possible compose features are currently available on Railway https://docs.railway.com/guides/dockerfiles#docker-compose.
At a glance it looks like your services all reference the same volume which could be a cause of the issues.


liangk
FREEOP

a month ago

I tried both {{Postgres.DATABASE_URL}} and {{DATABASE_URL}} and all response as empty string. I changed back to copy and paste the above string then made another PR. Suddenly all working. DB table created. Deploy log shows
Datasource "db": PostgreSQL database "railway", schema "public" at "maglev.proxy.rlwy.net:22488"

All good now. However, I still can't add a column to User table. So bad.
Anyway, thank you very much.


Status changed to Solved noahd about 1 month ago


Loading...