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:
Failed to connect to Postgres.: Io(Custom { kind: Uncategorized, error: "failed to lookup address information: Name does not resolve" })
Failed to connect to Postgres.: Io(Custom { kind: Uncategorized, error: "failed to lookup address information: Name does not resolve" })
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
Percy
Percyβ€’13mo ago
Project ID: c873a21a-2284-4ccd-8fc6-1291d0c4cacb
Mare Stare 😳
Mare Stare 😳OPβ€’13mo ago
My project ID is c873a21a-2284-4ccd-8fc6-1291d0c4cacb
MantisInABox
MantisInABoxβ€’13mo ago
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
Mare Stare 😳
Mare Stare 😳OPβ€’13mo ago
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.
MantisInABox
MantisInABoxβ€’13mo ago
It is in the docs. Caveats section, 5th bullet point https://docs.railway.app/reference/private-networking
Railway Docs
Private Networking | Railway Docs
Documentation for Railway
Mare Stare 😳
Mare Stare 😳OPβ€’13mo ago
Oh, right, lyrasweating
MantisInABox
MantisInABoxβ€’13mo ago
no problem
Want results from more Discord servers?
Add your server