R
Railway14mo ago
jea

Trying to run Phoenix/Elixir app, crash on startup

I'm trying to run an app on Railway for a Phoenix project but am getting this error:
=INFO REPORT==== 23-Oct-2023::16:57:16.708633 ===

Can't set long node name!

Please check your configuration

=CRASH REPORT==== 23-Oct-2023::16:57:16.708823 ===
=INFO REPORT==== 23-Oct-2023::16:57:16.708633 ===

Can't set long node name!

Please check your configuration

=CRASH REPORT==== 23-Oct-2023::16:57:16.708823 ===
I believe this is because I'm not setting RELEASE_NODE in my rel/env.sh.eex Has anyone else run in to? I'm not sure how to proceed here. I think I need to set RELEASE_NODE='<name>@<ip>' but I don't see a way to set the IP as an env var in railway as a reference.
57 Replies
Percy
Percy14mo ago
Project ID: da1de305-a4e0-4951-b1d6-63d209424a83
jea
jeaOP14mo ago
Project id: da1de305-a4e0-4951-b1d6-63d209424a83
Brody
Brody14mo ago
railway does not have static ips, you dont want to be using an ip for anything with that in mind, have a look at this docs section https://docs.railway.app/develop/variables#defining-variables
jea
jeaOP14mo ago
Yeah this would be a variable based on whatever IP railway has assigned the application. This is used for phoenix node clustering purposes Is there anyone else who has successfully deployed a phoenix application to railway? This is a very common use case for distributed elixir applications
Brody
Brody14mo ago
both the public and internal ips are dynamic, you would need to find a different way to differentiate between nodes in the cluster, perhaps the service id? maybe something like this would work for you? RELEASE_NODE=${{RAILWAY_SERVICE_NAME}}@${{RAILWAY_SERVICE_ID}}
jea
jeaOP14mo ago
that could work, are both of those set automatically?
Brody
Brody14mo ago
yep! those are reference variables and they would be rendered into the actual variable when your deploy is ran or when you click on the eye icon besides them https://docs.railway.app/develop/variables#reference-variables
jea
jeaOP14mo ago
i see, let me try that eh bad build, trying again okay its working but now im failing to connect to the db
Brody
Brody14mo ago
well whats the error lol
jea
jeaOP14mo ago
19:05:39.933 [error] Postgrex.Protocol (#PID<0.2022.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (containers-us-west-88.railway.app:7774): non-existing domain - :nxdomain
19:05:39.933 [error] Postgrex.Protocol (#PID<0.2022.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (containers-us-west-88.railway.app:7774): non-existing domain - :nxdomain
feels like it's not doing internal DNS?
Brody
Brody14mo ago
are you building with nixpacks?
jea
jeaOP14mo ago
nope, custom dockerfile
jea
jeaOP14mo ago
GitHub
opamp-elixir/Dockerfile at main · jaronoff97/opamp-elixir
This is an elixir implementation of the opamp-specification - jaronoff97/opamp-elixir
jea
jeaOP14mo ago
i can remove this and use nixpacks though if there's not a clear solution for this
Brody
Brody14mo ago
the dockerfile is fine
jea
jeaOP14mo ago
i went through the example repo, but didn't see anything standing out from it https://github.com/Nezteb/railway-elixir-phoenix/blob/main/config/runtime.exs
GitHub
railway-elixir-phoenix/config/runtime.exs at main · Nezteb/railway-...
Contribute to Nezteb/railway-elixir-phoenix development by creating an account on GitHub.
Brody
Brody14mo ago
wanna try setting the ENABLE_ALPINE_PRIVATE_NETWORKING=true service variable? i know you arent using alpine, but i think it may be worth a try
jea
jeaOP14mo ago
sure! one second rolling out now same problem
Brody
Brody14mo ago
okay, add a sleep for 3 seconds before you try connecting to the database
jea
jeaOP14mo ago
the sleep is controlled by phoenix so that may be a bitttt challenging, let me see if they have an option for that how would that help with this? it's continually retrying and failing
Brody
Brody14mo ago
just straight up add a sleep for 3 seconds, no need to overthink this the retries are full container restarts, thus the problem comes back on every retry you could even do CMD ["sleep 3", "/app/bin/server"]
jea
jeaOP14mo ago
it didn't seem like my application was crashing and restarting from the logs? ill give that a try though
Brody
Brody14mo ago
i said restart not redeploy
jea
jeaOP14mo ago
i also said restart, it seems its just retrying to connect from an alive server, not a "full container restart"
Brody
Brody14mo ago
you are misunderstanding me, no worries
jea
jeaOP14mo ago
kk just added a sleep to the command a very ominous "Container failed to start"
Brody
Brody14mo ago
then add the sleep in code
jea
jeaOP14mo ago
i don't think i'll be able to, there's no options for that in the library i'm using https://hexdocs.pm/ecto_sql/Ecto.Adapters.Postgres.html#module-connection-options
Brody
Brody14mo ago
you are extremely over thinking this in python the equivalent would be sleep(3) just place a sleep before you start the database connection
jea
jeaOP14mo ago
okay... ill give it a shot
jea
jeaOP14mo ago
still failing 😭 is it possible to ssh in to the container and try to curl out of it to see that it can connect to other resources? could this be because its trying to use ipv6 and that's not well supported?
jea
jeaOP14mo ago
maybe i should try using the internal service name? https://docs.railway.app/reference/private-networking
Railway Docs
Private Networking | Railway Docs
Documentation for Railway
Brody
Brody14mo ago
the internal network is ipv6 only so that would likely make things worse can you actually try disabling private networking?
jea
jeaOP14mo ago
sure, ill try that out
Protocol 'inet6_tcp': register/listen error: eaddrnotavail
Protocol 'inet6_tcp': register/listen error: eaddrnotavail
(this was only disabling private networking)
Brody
Brody14mo ago
why are you getting an inet6_tcp error?
jea
jeaOP14mo ago
not sure... i am trying to connect via ipv6 and that's not supported i guess? ¯\_(ツ)_/¯ should i disable ipv6 connections from my application when i don't have private networking?
Brody
Brody14mo ago
correct, the database plugins only have A type records
jea
jeaOP14mo ago
kk ill disable IPV6 rn hm same issue, let me manually disable it still no good hmm maybe it's not letting me bind to port correctly
Brody
Brody14mo ago
you want to bind to host 0.0.0.0 and the environment variable PORT
jea
jeaOP14mo ago
yeah... that's what im doing now hmmmmmmmmmmm im gonna mess around a bit more and try and figure it out okay getting back to this rn. From running my app locally with the exact same creds but removing ipv6 works, but if i add back the ipv6 socket option it fails in the same way im gonna just try disabling ipv6 in railway and see what happens 🤦‍♂️ that did the trick i have no clue why ipv6 didn't work
Brody
Brody14mo ago
disabling ipv6 in railway?
jea
jeaOP14mo ago
disabling the postgres ipv6 connection from my app
Brody
Brody14mo ago
Elixir problem then lol
jea
jeaOP14mo ago
made it work yeah big shrug
Brody
Brody14mo ago
real
jea
jeaOP14mo ago
im gonna chalk this up to some bug in someone's code somewhere that isn't mine. grepping around lots of forums, seems lots of people have this exact issue and setting the socket option works for some but not others
Brody
Brody14mo ago
that makes sense
jea
jeaOP14mo ago
maybe some elixir heads in another discord will have a better answer for me then "disable ipv6" but until then... good enough for me excited to have a working app
Brody
Brody14mo ago
pog
jea
jeaOP14mo ago
random question... would anyone from railway be opposed to me giving them a quick shoutout in a kubecon talk (good shoutout, not callout)
Brody
Brody14mo ago
i dont work for railway so i would have no clue
jea
jeaOP14mo ago
oh lmao the conductor really got me
Brody
Brody14mo ago
my bio says i dont work for railway 🙂
jea
jeaOP14mo ago
then i click in the profile haha yeah i am not on discord almost ever so i don't know to check these things thanks for the help regardless !
Brody
Brody14mo ago
no problem 🙂
Want results from more Discord servers?
Add your server