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:
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
Project ID:
da1de305-a4e0-4951-b1d6-63d209424a83
Project id:
da1de305-a4e0-4951-b1d6-63d209424a83
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
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
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}}
that could work, are both of those set automatically?
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
i see, let me try that
eh bad build, trying again
okay its working but now im failing to connect to the db
well whats the error lol
feels like it's not doing internal DNS?
are you building with nixpacks?
nope, custom dockerfile
GitHub
opamp-elixir/Dockerfile at main · jaronoff97/opamp-elixir
This is an elixir implementation of the opamp-specification - jaronoff97/opamp-elixir
i can remove this and use nixpacks though if there's not a clear solution for this
the dockerfile is fine
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.
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 trysure! one second
rolling out now
same problem
okay, add a sleep for 3 seconds before you try connecting to the database
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
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"]
it didn't seem like my application was crashing and restarting from the logs? ill give that a try though
i said restart not redeploy
i also said restart, it seems its just retrying to connect from an alive server, not a "full container restart"
you are misunderstanding me, no worries
kk just added a sleep to the command
a very ominous "Container failed to start"
then add the sleep in code
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
you are extremely over thinking this
in python the equivalent would be
sleep(3)
just place a sleep before you start the database connectionokay... ill give it a shot
don't overthink it https://hexdocs.pm/elixir/Process.html#sleep/1
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?
maybe i should try using the internal service name? https://docs.railway.app/reference/private-networking
the internal network is ipv6 only
so that would likely make things worse
can you actually try disabling private networking?
sure, ill try that out
(this was only disabling private networking)
why are you getting an inet6_tcp error?
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?
correct, the database plugins only have A type records
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
you want to bind to host 0.0.0.0 and the environment variable PORT
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
disabling ipv6 in railway?
disabling the postgres ipv6 connection from my app
Elixir problem then lol
made it work
yeah
big shrug
real
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
that makes sense
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
pog
random question... would anyone from railway be opposed to me giving them a quick shoutout in a kubecon talk
(good shoutout, not callout)
i dont work for railway so i would have no clue
oh lmao
the conductor really got me
my bio says i dont work for railway 🙂
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 !
no problem 🙂