Application failed to access database

Hey, while I'm trying to run a webapp, the container fails to connect to any databases. Redis shows timeout, while Prisma (PostgreSQL) shows unreachable. But when I run it locally, everything connects.
Solution:
currently it takes around 100ms for railnet0 (the private networking interface) to become bound, and then up to 3 seconds before the private network's dns server will resolve internal domains) in these time frames, even though you aren't using the private network, external requests can behave very wonky
Jump to solution
23 Replies
Percy
Percy13mo ago
Project ID: 365c4033-f34a-46b5-93ba-f8cf23b3211c
Brody
Brody13mo ago
can i see a screenshot of your service variables?
The Big E in Math -> Σ
I'm using railway's database service so database variables are automatically injected. Prisma also shows the database url when thrown error, which confirms that there's no issue with the variable.
Brody
Brody13mo ago
please show me the screenshot anyways
Brody
Brody13mo ago
where are your postgres and redis databases hosted?
The Big E in Math -> Σ
in the railway project
Brody
Brody13mo ago
delete the current database variables and setup the variable references for them please https://docs.railway.app/develop/variables#railway-provided-variables then show me another screenshot
The Big E in Math -> Σ
Well looks like that fixes it. Though the deployment log still shows bunch of timeout and connection error messages.
Brody
Brody13mo ago
then show me another screenshot please
Brody
Brody13mo ago
there we go do you have private networking turned on in the service settings?
The Big E in Math -> Σ
I believe it is
Brody
Brody13mo ago
are you utilizing the private network?
The Big E in Math -> Σ
yup, is that affecting external connections?
Brody
Brody13mo ago
ideally it shouldn't, but there's some caveats of the private networking system that have a slim chance of causing issues with network requests that are done right when the app starts
The Big E in Math -> Σ
Well, that probably explains the initial connection errors.
Brody
Brody13mo ago
disable it and let me know how it goes
The Big E in Math -> Σ
Confirmed, the inital connection errors no longer occurs.
Brody
Brody13mo ago
unfortunately they went ahead and made private network enabled by default before some of the issues where fixed
Solution
Brody
Brody13mo ago
currently it takes around 100ms for railnet0 (the private networking interface) to become bound, and then up to 3 seconds before the private network's dns server will resolve internal domains) in these time frames, even though you aren't using the private network, external requests can behave very wonky
The Big E in Math -> Σ
Good to know. Hopefully the network system will improve later on.
Brody
Brody13mo ago
I'm sure they will