Fly.io: The app is not listening on the expected address and will not be reachable by fly-proxy

I’m trying to deploy an existing Phoenix app to fly.io. After a few tries it seems to work, but now I get the “The app is not listening on the expected address and will not be reachable by fly-proxy.” error.

The log then proceeds to print this:

Found these processes inside the machine with open listening sockets:
  PROCESS

                                                          | ADDRESSES
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------*---------------------------------------
  /app/erts-13.1.3/bin/beam.smp -- -root /app -bindir /app/erts-13.1.3/bin -progname erl -- -home /nonexistent -- -proto_dist inet6_tcp -- -noshell -s elixir sta
rt_cli -mode embedded -setcookie PWOVL6U2DQUEE7V7BNYSLJPK2XG7CYEZPH6MS4Y2QJQDIW6R7E4A==== -sname magpie -config /app/releases/2.3.4/sys -boot /app/releases/2.3.4
/start -boot_var RELEASE_LIB /app/lib -- -extra --no-halt | [::]:33127
  /.fly/hallpass

                                                          | [fdaa:2:6f01:a7b:141:65dd:fe42:2]:22
  /app/erts-13.1.3/bin/epmd -daemon

                                                          | 0.0.0.0:4369, [::]:4369

Curiously, the first item in the list seems to be my app? I have no idea why it’s listening on 33127 though.

I tried to run fly deploy again, and now it’s on 40627.

Is this the app process, or is this something irrelevant?

I checked my runtime.exs, prod.exs and config.exs against a vanilla new project, which I was able to deploy successfully, and I seem to find no difference in terms of the port configuration… (I still don’t know where the “8080” is supposed to come from in the first place though.)

OK I finally saw this line from the logs:

Configuration :server was not enabled for Magpie.Endpoint, http/https services won't start

I have no idea why this is the case, since my rel/overlays/bin/server has exactly the same content as the vanilla test app:

#!/bin/sh
cd -P -- "$(dirname -- "$0")"
PHX_SERVER=true exec ./magpie start

But anyways I removed the conditional part on

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

in my runtime.exs and it finally worked.

1 Like

May I know from which logs you have seen this? Deployment noobie here:)

It’s just the normal application logs printed to the stdout from what I remember. I just missed that important line. Don’t remember how to exactly check for them on fly.io (either via the fly command line tool or via the website UI should be possible) but there should be documentation for that.

Ty for your reply! Btw I’d also be curious to know as to why you conditionally set the config :server to true as seen here:

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