running my prod release locally results in [error] GenServer DNSCluster terminating ** (FunctionClauseError) no function clause matching in :inet_dns.encode_labels/4

I tried to run my prod release locally using this command:
MIX_ENV=prod APP_NAME=wailee PORT=4000 _build/prod/rel/myapp/bin/myapp start

This is the error message I’m getting:

15:36:29.712 [error] GenServer DNSCluster terminating
** (FunctionClauseError) no function clause matching in :inet_dns.encode_labels/4
    (kernel 9.2.4) inet_dns.erl:883: :inet_dns.encode_labels(<<0, 4, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0>>, {0, nil}, 12, ["", "internal"])
    (kernel 9.2.4) inet_dns.erl:861: :inet_dns.encode_name/4
    (kernel 9.2.4) inet_dns.erl:304: :inet_dns.encode_query_section/3
    (kernel 9.2.4) inet_dns.erl:275: :inet_dns.encode/1
    (kernel 9.2.4) inet_res.erl:694: :inet_res.make_query/5
    (kernel 9.2.4) inet_res.erl:657: :inet_res.make_query/4
    (kernel 9.2.4) inet_res.erl:628: :inet_res.res_query/5
    (kernel 9.2.4) inet_res.erl:597: :inet_res.res_getby_query/3
Last message: {:continue, :discover_ips}

Here’s my runtime.exs:

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

if config_env() == :prod do
# The secret key base is used to sign/encrypt cookies and other secrets.
# A default value is used in config/dev.exs and config/test.exs but you
# want to use a different value for prod and you most likely don't want
# to check this value into version control, so we use an environment
# variable instead.
secret_key_base =
System.get_env("SECRET_KEY_BASE") ||
raise """
environment variable SECRET_KEY_BASE is missing.
You can generate one by calling: mix phx.gen.secret
"""

host = System.get_env("PHX_HOST") || "example.com"
port = String.to_integer(System.get_env("PORT") || "4000")

config :MyApp, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")

config :MyApp, MyAppWeb.Endpoint,
url: [host: host, port: 443, scheme: "https"],
http: [
# Enable IPv6 and bind on all interfaces.
# Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
# See the documentation on https://hexdocs.pm/bandit/Bandit.html#t:options/0
# for details about using IPv6 vs IPv4 and loopback vs public addresses.
ip: {0, 0, 0, 0, 0, 0, 0, 0},
port: port
],
secret_key_base: secret_key_base,
server: true

This is a very simple phoenix app. I’ve only added nimble_publisher and a couple of other very simple dependencies so far.

Thanks in advance.

What’s the value of the env variable DNS_CLUSTER_QUERY? If you’re running this in your local machine you have configure your router or system’s DNS server to resolve local IP addresses.

1 Like

Thanks for your help!

Your response led me to this post:

Like the initiator of the above thread, I decided to remove the dns_cluster dependency.

Here are the basic steps:

  1. removed {:dns_cluster, "~> 0.1.1"} from deps in mix.exs
  2. removed {DNSCluster, query: Application.get_env(:wailee, :dns_cluster_query) || :ignore}, from the supervision tree in application.ex
  3. ran mix deps.get

and built another production release locally. This one works!

Thanks again!

2 Likes

If you’re just trying things out locally or don’t plan to host a system with multiple nodes then removing it is fine.

Happy coding and welcome to the community :+1:

1 Like