R
Railway14mo ago
barron

Elixir failing to connect to Postgres - non-existing domain

Seeing errors trying to connect to a postgres DB from an elixir project. I'm using the ${{postgresql.DATABASE_URL}} variable and it's being correctly logged But seeing "failed to connect" errors: 19:53:10.228 [error] Postgrex.Protocol (#PID<0.2263.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (containers-us-west-156.railway.app:5642): non-existing domain - :nxdomain I'm assuming the problem is related to TCP and/or private networking. I tried to use ${{postgresql.PRIVATE_DATABASE_URL}} from the docs, but it didn't work — it looked like the postgres instance didn't have that variable by default when created. Project ID: 7142b0a0-bc81-4fff-8904-4ddbafc19380
No description
21 Replies
Percy
Percy14mo ago
Project ID: 7142b0a0-bc81-4fff-8904-4ddbafc19380
Brody
Brody14mo ago
can you try increasing the connection timeout or put the connection attempt on a retry loop
barron
barron14mo ago
Sure, let me try! It is trying repeatedly for context but will adjust timeout
barron
barron14mo ago
No description
Brody
Brody14mo ago
is this the code is trying repeatedly or is this railway re-running the crashed app?
barron
barron14mo ago
trying repeatedly
Brody
Brody14mo ago
would you happen to be building with a dockerfile?
barron
barron14mo ago
GitHub
mayor_game/Dockerfile at main · warronbebster/mayor_game
trying to make a civil engineering MMO. Contribute to warronbebster/mayor_game development by creating an account on GitHub.
Brody
Brody14mo ago
so you aren't using an alpine based image?
barron
barron14mo ago
I don't believe so, no
Brody
Brody14mo ago
we'll try setting this anyway ENABLE_ALPINE_PRIVATE_NETWORKING=true (in the service variables)
barron
barron14mo ago
nope, same error
Brody
Brody14mo ago
what dns resolver is your code using for the lookup?
barron
barron14mo ago
I'm not sure exactly? Most of the project config is here: https://github.com/warronbebster/mayor_game/blob/main/config/config.exs
GitHub
mayor_game/config/config.exs at main · warronbebster/mayor_game
trying to make a civil engineering MMO. Contribute to warronbebster/mayor_game development by creating an account on GitHub.
Brody
Brody14mo ago
not quite what I asked use 8.8.8.8 for the domain lookup during connecting to postgres
barron
barron14mo ago
I'm not exactly sure how to do that 😅
Brody
Brody14mo ago
that's what stack overflow is for 🤣
barron
barron14mo ago
wouldn't the dns resolution be on railway's end?
Brody
Brody14mo ago
unless you are using the private domain, no and something in your setup has borked domain resolution, so try overriding the dns server during connection to 8.8.8.8
barron
barron14mo ago
ok, I'll look into that, ty In the docs, it says "Railway databases are not accessible via the private network, we are moving towards a system where DBs are services with volumes attached." — Does that mean it needs to be connected through the TCP proxy?
Brody
Brody14mo ago
that is talking about the old databases, but yes you should get the database working through the tcp proxy first
Want results from more Discord servers?
Add your server