Private DNS resolution doesn't work
Hey I'm trying to deploy a test Rust axum, sqlx app that needs to connect to a Postgres instance. I'm using the
DATABASE_PRIVATE_URL
of the Postgres instance in the axum service. But my app can't connect to the instance with the DNS error:
I clearly see that the DB URL that it uses is of form postgres://postgres:[email protected]:5432/railway
and that private network is enabled. What could be wrong here? Can I SSH to the server to debug this somehow?7 Replies
Project ID:
c873a21a-2284-4ccd-8fc6-1291d0c4cacb
My project ID is c873a21a-2284-4ccd-8fc6-1291d0c4cacb
This is because of the initialization time of the private network. You will want to sleep your app for about 3 seconds or so to ensure that the private network is fully up before trying to connect over it
Your app is starting up faster than the network initializes
Also, there is no way to ssh into the containers
Aha, I see, that's a caveat. I guess a better way to deal with this is to use an exponential retry for db connection. It would be nice to mention this in the docs.
It is in the docs. Caveats section, 5th bullet point
https://docs.railway.app/reference/private-networking
Oh, right,
no problem