[error] Postgrex.Protocol (#PID<0.137.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (top2.nearest.of.my-pleroma-app-db.internal:5432): non-existing domain - :nxdomain

Trying to deploy Pleroma: (a federated social platform built on Elixir/Phoenix) Files · develop · Pleroma / pleroma · GitLab

There is a Docker container maintained by a community member here: GitHub - angristan/docker-pleroma: Docker image for the Pleroma federated social network

I found several similar community posts, tried all of the proposed solutions, but none of them worked for me:

When using fly launch for the initial config, I opted to also create and link a Postgres DB to the app.

My fly.toml:

app = "my-pleroma-app"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]
  ADMIN_EMAIL = "my@email.com"
  # DB_HOST = "top2.nearest.of.my-pleroma-app-db.internal"
  DB_HOST = "my-pleroma-app-db.internal"
  DB_NAME = "my_pleroma_app_db"
  DB_USER = "my_pleroma_app_db"
  DOMAIN = "my-pleroma-app.fly.dev"
  INSTANCE_NAME = "My Pleroma App"
  NOTIFY_EMAIL = "my@email.com"

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[mounts]]
  destination = "/var/lib/pleroma"
  source = "my_pleroma_app_data"

[[services]]
  http_checks = []
  internal_port = 4000
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"
❯ fly secrets list
NAME
DATABASE_URL
DB_PASS

With all of this, fly deploy fails when running Ecto migrations because of:

[error] Postgrex.Protocol (#PID<0.137.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (top2.nearest.of.my-pleroma-app-db.internal:5432): non-existing domain - :nxdomain

One thing to note: I didn’t set DB_HOST to top2.nearest.of.my-pleroma-app-db.internal, I set it to my-pleroma-app-db.internal, but having read through the docs, I don’t understand why this happens? Fly Postgres · Fly Docs

DISREGARD.

I hadn’t fully read/understood one of the comments I found in a different thread: Connected Postgres DB Throws Domain not found error - #22 by andreyuhai

The Ecto repo needs to be configured to accept IPv6 connetions, like so:

config :pleroma, Pleroma.Repo,
  adapter: Ecto.Adapters.Postgres,
  username: System.get_env("DB_USER", "pleroma"),
  password: System.fetch_env!("DB_PASS"),
  database: System.get_env("DB_NAME", "pleroma"),
  hostname: System.get_env("DB_HOST", "db"),
  pool_size: 10,
  socket_options: [:inet6] # THIS IS THE THING

Neither Pleroma nor the community-maintained Dockerfile I was using had this set. :man_facepalming:

1 Like

Glad you got it resolved!