Has anyone successfully launched an Elixir app with postgres?

I followed their fly launch guide and it should be straightforward and it should work out of the box after they inject the DATABASE_URL, but it just keeps failing and I haven’t been able to figure out why.

Anyone here figure out how?

INFO [fly api proxy] listening at /.fly/api
  2023/08/14 07:35:35 listening on [fdaa:2:c486:a7b:d829:3bff:2a58:2]:22 (DNS: [fdaa::3]:53)
  07:35:36.341 [error] Postgrex.Protocol (#PID<0.141.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (my-app-name-db.flycast:5432): non-existing domain - :nxdomain
  07:35:36.341 [error] Postgrex.Protocol (#PID<0.140.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (my-app-name-db.flycast:5432): non-existing domain - :nxdomain
  07:35:37.693 [error] Postgrex.Protocol (#PID<0.140.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (my-app-name-db.flycast:5432): non-existing domain - :nxdomain
  07:35:38.029 [error] Postgrex.Protocol (#PID<0.141.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (my-app-name-db.flycast:5432): non-existing domain - :nxdomain
  07:35:39.302 [error] Could not create schema migrations table. This error usually happens due to the following:
    * The database does not exist

My app is using the this in runtime:

    url: System.fetch_env!("DATABASE_URL"),
    pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")

I suspect this is wrong?

(my-app-name-db.flycast:5432): non-existing domain - :nxdomain

Specific my-app-name-db.flycast.

Either the DATABASE _URL is wrong or you’re overwriting it in config file with example value.


That’s what I suspected at first as well, but it was correct. I am assuming they are doing some kind of internal routing with docker images.

Do you have this in your Repo config

socket_options: [:inet6]


I have it in my runtime, but it’s commented out. Do you think this has to something to do with it?

I remember this was a problem for me.
Fly apps communicate using IP v6.

You should have something like this in your runtime.exs

  config :my_app, MyAppWeb.Endpoint,
    server: true,
    url: [host: endpoint_host, port: 80],
    http: [
      port: 4000,
      # IMPORTANT: support IPv6 addresses
      transport_options: [socket_opts: [:inet6]]

and similarly this

  config :my_app, MyApp.Repo.Local,
    url: database_url,
    # IMPORTANT: Or it won't find the DB server
    socket_options: [:inet6],
    pool_size: 10,
1 Like

Ah maybe that is it! Thank you for the help.

Actually, in that short time, I ended up switching over to railway.app instead. I’ve found a lot of little things a lot better in railway.app than render and fly.io. From env var management to ease of spinning up services to support. The developer experience was much better than the other two.

If anyone wants my referral link, I can send it to you!

1 Like

Please do, I’m interested.

I sent you a DM. I wasn’t sure if we can post referral links here.

1 Like

I received it, thank you!

1 Like

I personally think all the paas(fly, render, railway) while easy to deploy end up having quite a bit of limitations as you start using them. Have found Porter to have a better dev ex and scales with you since its in your own AWS- but probably only the best option if you have credits.

Wow the base cost is $225 a month. This might be more fit for companies with on-prem requirements. I’m trying to move away from having to deal with AWS in any capacity since it’s overkill for my use cases.