Using DATABASE_URL with private networking on an Elixir project
languageleague
TRIALOP

2 years ago

I've set up my server to use the internal domain name on my Elixir project (which uses an alpine image, so I set the respective ENABLE_ALPINE_PRIVATE_NETWORKING=true environment variable as to some docs I read) but the database connection is failing with a nxdomain error.

18:59:23.065 [error] Postgrex.Protocol (#PID<0.2856.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (database.railway.internal:5432): non-existing domain - :nxdomain

Any idea on how I can solve this?

11 Replies

2 years ago

The private network is IPv6 only, so your client would need to be able to do AAAA lookups.


languageleague
TRIALOP

2 years ago

I assume I have to set up my image so that it can do this, right? Would you be able to help me on that or link me to some resource?


2 years ago

I'm sorry but I have no experience with Elixir, but the issue wouldn't be specific to Railway so please do some research on this topic.


languageleague
TRIALOP

2 years ago

It is not an elixir issue. I've set up the DB to connect with ipv6 already. However, my image won't let me enable ipv6 through this command

RUN sysctl -w net.ipv6.conf.all.disable_ipv6=0

It throws this error:

0.095 sysctl: error setting key 'net.ipv6.conf.all.disable_ipv6': Read-only file system

Which apparently can happen if there's not enough space but I'm sure there is.

This issue says it can be solved by running the option within docker run, but I'm not sure I have access to that

https://github.com/docker/for-linux/issues/197#issuecomment-504042561

Any other help?


languageleague
TRIALOP

2 years ago

Also, after removing the IPV6 command and recompiling, the api errors out and displays a railway-branded error page but no logs are provided anywhere and neither does the server display any abnormal or DB connection errors, which is extremely annoying.


2 years ago

You don't need to enable IPv6, the private network is already IPv6, as long as your database client supports IPv6, it will work.

If you aren't seeing any logs that means you aren't logging unbuffered to stdout / stderr.


languageleague
TRIALOP

2 years ago

Every single request is logged, it was logged before and it just stopped logging as soon as I enabled IPV6 on my DB connection


2 years ago

If you are properly logging you will see the logs in the deploy logs section.


languageleague
TRIALOP

2 years ago

No. The requests are not even getting to my server, I'm getting a 503 error. Here are the logs before and after the IPV6 config change


languageleague
TRIALOP

2 years ago

I'm pretty sure Railway is only checking if the DNS CNAME record contains up.railway.app and not the exact domain name for verification and that's causing issues somewhere. I just changed my domain from api to api2 (which i'd already used before and thus had an expired railway CNAME record) and it instantly told me it was correctly set up even though the wasn't even changed.


languageleague
TRIALOP

2 years ago

Yup, changing the domain to api3 fixed everything.


Loading...