Private Networking Failing to Provide DB Connection
austinkettner
PROOP

a year ago

This deployment cannot reach the DB with the Railway DATABASE URL, both are running the new builder, both are US-east. However, Prisma during build time can't reach the DB

View Deploy details

ⓘ Deployment information is only viewable by project members and Railway employees.

Solved

3 Replies

chandrika
EMPLOYEE

a year ago

Hi Austin!

The private network is unavailable during build phase — could you please use the public url during the build phase and use the private url within your application (to keep the egress usage low)?


Status changed to Awaiting User Response Railway about 1 year ago


austinkettner
PROOP

a year ago

How would you suggest this be done without code-level changes


Status changed to Awaiting Railway Response Railway about 1 year ago


chandrika
EMPLOYEE

a year ago

You could do this without making code changes by setting up a different service variable for the public URL. So your service variables would be something like (assuming you are using DATABASE_URL ):
```
DATABASE_URL=${{Postgres.DATABASE_URL}} DATABASE_PUBLIC_URL=${{Postgres.DATABASE_PUBLIC_URL}}
```

You'd use the DATABASE_PUBLIC_URL with the inline assignment 'DATABASE_URL=$DATABASE_PUBLIC_URL by adding it to your nixpacks.toml

```
[phases.migrate]
dependsOn = ['install']

cmds = ['DATABASE_URL=$DATABASE_PUBLIC_URL npm run migrations'] # your own migration command goes here
```

and continue using DATABASE_URL in the application code (assuming that is the variable name you are using)


Status changed to Awaiting User Response Railway about 1 year ago


Railway
BOT

4 months ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway 4 months ago


Loading...