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
21 Replies
Project ID:
7142b0a0-bc81-4fff-8904-4ddbafc19380
can you try increasing the connection timeout or put the connection attempt on a retry loop
Sure, let me try!
It is trying repeatedly for context
but will adjust timeout
is this the code is trying repeatedly or is this railway re-running the crashed app?
trying repeatedly
would you happen to be building with a dockerfile?
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.
so you aren't using an alpine based image?
I don't believe so, no
we'll try setting this anyway
ENABLE_ALPINE_PRIVATE_NETWORKING=true
(in the service variables)nope, same error
what dns resolver is your code using for the lookup?
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.
not quite what I asked
use 8.8.8.8 for the domain lookup during connecting to postgres
I'm not exactly sure how to do that 😅
that's what stack overflow is for 🤣
wouldn't the dns resolution be on railway's end?
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
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?
that is talking about the old databases, but yes you should get the database working through the tcp proxy first