Can't connect to internal postgres

both of apps are on the same organization, and this is my p[heonix app config:

database_url =
    System.get_env("DATABASE_URL") ||
      raise """
      environment variable DATABASE_URL is missing.
      For example: ecto://USER:PASS@HOST/DATABASE
      """

  config :fuschia, Fuschia.Repo,
  ssl: false, # fly.io don't need
    url: database_url,
    pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
    socket_options: [:inet6]

however I’m getting this error:

17:58:56.369 [error] GenServer #PID<0.390.0> terminating
** (DBConnection.ConnectionError) tcp connect (fuschia-db.internal:5432): non-existing domain - :nxdomain
    (db_connection 2.4.1) lib/db_connection/connection.ex:100: DBConnection.Connection.connect/2
    (connection 1.1.0) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.17) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

Hello! Which version of Phoenix is this? You may need to follow these instructions to make IPv6 address lookups work: Deploy an Elixir Phoenix Application (pre v1.6.3) · Fly Docs

The socket_options in your config solve part of the problem, but not all of it.

Thank you for these docs link! I didn’t find tit. I made those suggested changes and now my app can run migrations! However it’s stills failing on healthcheck with:

3df2415693844068640885b45074b954 tcp-8080 critical dial tcp 172.19.6.234:8080: connect: connection refused

I’m trying to figure out a possible error in my runtime.exs:

import Config

config :tesla, :adapter, {Tesla.Adapter.Finch, name: HttpClientFinch}

# ---------------------------#
# Logger
# ---------------------------#
config :logger, :console,
  format: "$time $metadata[$level] $message\n",
  metadata: [:request_id],
  backends: [:console, Sentry.LoggerBackend]

# ---------------------------#
# Sentry
# ---------------------------#
config :sentry,
  dsn: System.get_env("SENTRY_DNS"),
  environment_name: config_env(),
  enable_source_code_context: true,
  root_source_code_path: File.cwd!(),
  tags: %{
    env: "production"
  },
  included_environments: [System.get_env("SENTRY_ENV")]

# ---------------------------#
# Oban
# ---------------------------#
config :fuschia, Oban,
  repo: Fuschia.Repo,
  queues: [mailer: 5]

config :fuschia, :jobs, start: System.get_env("START_OBAN_JOBS", "true")

# ---------------------------#
# Timex
# ---------------------------#
config :timex, timezone: System.get_env("TIMEZONE", "America/Sao_Paulo")

if System.get_env("PHX_SERVER") do
  config :fuschia, FuschiaWeb.Endpoint, server: true
end

if config_env() == :prod do
  database_url =
    System.get_env("DATABASE_URL") ||
      raise "DATABASE_URL not available"

  if System.get_env("ECTO_IPV6") do
    config :fuschia, Fuschia.Repo,
      socket_options: [:inet6]
  end

  config :fuschia, Fuschia.Repo,
  ssl: false, # fly.io don't need
    url: database_url,
    pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")

  secret_key_base =
    System.get_env("SECRET_KEY_BASE") ||
      raise "SECRET_KEY_BASE not available"

  app_name =
    System.get_env("FLY_APP_NAME") ||
      raise "FLY_APP_NAME not available"

  config :fuschia, FuschiaWeb.Endpoint,
    url: [host: "#{app_name}.fly.dev", port: 80],
    http: [
      ip: {0, 0, 0, 0, 0, 0, 0, 0},
      port: String.to_integer(System.get_env("PORT") || "4000")
    ],
    secret_key_base: secret_key_base
end

Also my project is open source: GitHub - cciuenf/fuschia: Plataforma Digital PEA Pescarte

changing grace_period to 10s on tcp check step didn’t take effect too. I’m still investigating

this is the complete log

2022-07-16T17:32:48.370 runner[1f61ad9a] gru [info] Starting instance

2022-07-16T17:32:48.585 runner[1f61ad9a] gru [info] Configuring virtual machine

2022-07-16T17:32:48.587 runner[1f61ad9a] gru [info] Pulling container image

2022-07-16T17:32:50.570 runner[1f61ad9a] gru [info] Unpacking image

2022-07-16T17:32:50.575 runner[1f61ad9a] gru [info] Preparing kernel init

2022-07-16T17:32:52.258 runner[1f61ad9a] gru [info] Configuring firecracker

2022-07-16T17:32:52.382 runner[1f61ad9a] gru [info] Starting virtual machine

2022-07-16T17:32:52.538 app[1f61ad9a] gru [info] Starting init (commit: c86b3dc)...

2022-07-16T17:32:52.553 app[1f61ad9a] gru [info] Preparing to run: `sh start.sh` as nobody

2022-07-16T17:32:52.570 app[1f61ad9a] gru [info] 2022/07/16 17:32:52 listening on [fdaa:0:7774:a7b:1f60:1f61:ad9a:2]:22 (DNS: [fdaa::3]:53)

2022-07-16T17:32:54.488 app[1f61ad9a] gru [info] 17:32:54.485 [info] Migrations already up

2022-07-16T17:32:54.564 app[1f61ad9a] gru [info] Reaped child process with pid: 568 and signal: SIGUSR1, core dumped? false

2022-07-16T17:32:54.565 app[1f61ad9a] gru [info] Reaped child process with pid: 601, exit code: 0

2022-07-16T17:32:57.380 app[1f61ad9a] gru [info] 17:32:57.379 [info] Running FuschiaWeb.Endpoint with cowboy 2.9.0 at :::4000 (http)

2022-07-16T17:32:57.382 app[1f61ad9a] gru [info] 17:32:57.381 [info] Access FuschiaWeb.Endpoint at http://fuschia.fly.dev

2022-07-16T17:32:57.570 app[1f61ad9a] gru [info] Reaped child process with pid: 622 and signal: SIGUSR1, core dumped? false

2022-07-16T17:33:01.127 app[1f61ad9a] gru [info] 17:33:01.126 [info] tzdata release in place is from a file last modified Fri, 22 Oct 2021 02:20:47 GMT. Release file on server was last modified Wed, 16 Mar 2022 13:36:02 GMT.

2022-07-16T17:33:02.059 runner[47f734ea] gru [info] Shutting down virtual machine

2022-07-16T17:33:02.186 app[47f734ea] gru [info] Sending signal SIGINT to main child process w/ PID 515

2022-07-16T17:33:02.535 app[1f61ad9a] gru [info] 17:33:02.534 [info] Tzdata has updated the release from 2021e to 2022a

2022-07-16T17:38:02.864 runner[1f61ad9a] gru [info] Shutting down virtual machine

2022-07-16T17:38:02.990 app[1f61ad9a] gru [info] Sending signal SIGINT to main child process w/ PID 515