Conn.remote_ip question - After building a release with distillery the remote_ip is {0, 0, 0, 0, 0, 65535, 23502, 9539}

I have a problem regarding conn.remote_ip, when I try to access the remote_ip from dev environment I have a successful result: {91, 206, 37, 67} after starting server with following command: iex -S mix phx.server
After building a release with distillery the remote_ip a tuple equal with {0, 0, 0, 0, 0, 65535, 23502, 9539}

Do you know what are the problems ?

It seems that the server you run your release on prefers IPv6 addresses. If you don’t want that I think your only option is configuring the server to accept only IPv4 addresses.

I’m running release and iex -S mix phx.server on same server, that’s strange…

Probably because you are constraining it to an IP in dev.exs (0.0.0.0?) and leaving it unconstrained in prod.exs or so?

I looked a bit into it and I think it is because of this function that is by default called only in in :prod and is located at the bottom of your endpoint.ex:

def load_from_system_env(config) do
    port = System.get_env("PORT") || raise "expected the PORT environment variable to be set"
    {:ok, Keyword.put(config, :http, [:inet6, port: port])}
end

Notice the :inet6 entry in the http configuration. I haven’t tested it, but with a bit of luck changing that to :inet solves your issue.

EDIT: changed :inet4 to :inet

1 Like

Right now works. Thanks a lot :slight_smile: