a year ago
I have a project with one web service and one Postgres database spun up on Railway. I can see on the database's side that the environment variables DATABASE_URL (on switchback.proxy.rlwy.net) and DATABASE_PRIVATE_URL (on postgres.railway.internal). However, when I attempt to reference the DATABASE_URL from my web service, it reflects instead the DATABASE_PRIVATE_URL no matter what. This makes it impossible to use Railway's CLI tooling to connect to my database easily to create tables. Can you help me with this?
5 Replies
Unsure if this is your issue but the variable name is; DATABASE_PUBLIC_URL for the public URL and not DATABASE_URL.
yeah I think angel is right here. I'd check a couple of things if you haven't already:
- On the Postgres deployment, check Settings > Networking to ensure the Public network TCP proxy is indeed setup. You should see something like
shuttle.proxy.rlwy.net:port -> :5432 - On variables, check that you have the reference variable
{} DATABASE_PUBLIC_URL, which should be the connection string to your TCP proxy service
a year ago
If I remember it correctly, in the past, the two connection string variables provided when the database was created were DATABASE_PRIVATE_URL (private) and DATABASE_URL (public).
This has since been changed to DATABASE_PUBLIC_URL (public) and DATABASE_URL (private).
a year ago
What you could try is to rename the variable names using the raw editor and replace DATABASE_PRIVATE_URL with DATABASE_URL and DATABASE_URL with DATABASE_PUBLIC_URL.
For reference, this is how the two connection string variables are defined for newly created postgres databases.
DATABASE_PUBLIC_URL="postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_TCP_PROXY_DOMAIN}}:${{RAILWAY_TCP_PROXY_PORT}}/${{PGDATABASE}}"
DATABASE_URL="postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:5432/${{PGDATABASE}}"