Azure app service claims non-existing domain - but it works on my machine

Hello!
I am setting up a phoenix app and want to deploy it on Azure app service.

I run the docker image locally, and can connect to the Azure postgres app.
When I use the same image for app deployment I get this error

2025-02-01T21:23:27.0698211Z 21:23:27.069 [error] Postgrex.Protocol (#PID<0.2973.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (company-name-staging.postgres.database.azure.com:5432): non-existing domain - :nxdomain

config:

config :company-name, App.Repo,
    ssl: true,
    ssl_opts: [
      stacktrace: true,
      protocol: :tls,
      protocol_version: :"tlsv1.3",
      verify: :verify_peer,
      cacertfile: "/etc/ssl/certs/ca-certificates.crt",
      server_name_indication: String.to_charlist(pghostname),
      verify_fun:
        {&:ssl_verify_hostname.verify_fun/3,
          [check_hostname: String.to_charlist(pghostname)]}
    ],
    database: pgdatabase,
    username: pgusername,
    password: pgpassword,
    hostname: pghostname,
    pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")

bonus weirdness:
in my start up script I run
psql "host=<hostname>.database.azure.com port=5432 dbname=postgres user=admin password=$PGPASSWORD" -c "SELECT * FROM users;"
and I can connect to the db even from deployed app

the database’s authentication method is PostgreSQL user and password only

tagging @chgeuer could you please recommend anything?

Is the hostname you have configured vitvio-staging.postgres.database.azure.com:5432? Like with the port number? When it says vitvio-staging.postgres.database.azure.com:5432: non-existing domain, that certainly makes sense, because the domain would just be vitvio-staging.postgres.database.azure.com. Maybe you should do

hostname: "vitvio-staging.postgres.database.azure.com",
port: 5432
1 Like

that’s not it, and I can connect to it using the same credentials and the same db name from an image running on my machine. I had to configure the ssl certificates for that too.

I initially thought you might have a problem that there’s a VNET that has another PostgreSQL included via private endpoint, but that seems not to be the case.

I see you’re already having a support ticket open from Friday, I’d say let’s give them a change to dig deeper. Feel free to include me in your mails with support (mailto:chgeuer@…)

One question: You say in your “start up script” you can run psql and connect to the host, but then your Elixir app can’t, do I understand this right? Are both the startup script and the BEAM instance run in the same docker container?

BTW, I see you redacted the hostname in your original post, after I cited it in my reply above. Let me know whether I should delete my reply.

1 Like

yes, deleting or redacting hostname would be good.

the answer to your question is yes.

I found out the culprit!!! It was IPv6 setting we set to true for the application!!!
and it’s not supported in UK South

Perfect, glad you found it… I can’t delete or edit my reply above, unfortunately…

1 Like

Hey @agata-anastazja , one more question: That IPv6 setting, was that on the Elixir application code side, or an app service plan setting in the Azure Portal? Or on Postgres? If you have a screenshot of the setting that led to the problem, would love to see.

it was on the application code side. We had set it in env.sh.eex

# configure node for distributed erlang with IPV6 support

export ERL_AFLAGS="-proto_dist inet6_tcp"
export ECTO_IPV6="true"
1 Like

Thanks for clarifying